> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/release-1.3.0/configuration-reference/functions/first_value.md).

# FIRST\_VALUE

The `FIRST_VALUE` function returns the value from the first row in a window.&#x20;

### Signature

```sql
FIRST_VALUE(expression) [IGNORE NULLS | RESPECT NULLS] OVER ()
```

The default behavior is `RESPECT NULLS`. If the `IGNORE NULLS` option is specified, the function returns the first non-null row in each window (assuming one exists, `null` otherwise).

### Example

This example computes the number of games played by a player in their first year.

```sql
SELECT playerName,
  yearID,
  numberOfGames,
  FIRST_VALUE(numberOfGames) OVER (
    PARTITION BY playerName
    ORDER BY yearID ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
  )
FROM baseballStats;
```

Output:

<table><thead><tr><th>playerName</th><th>yearID</th><th>numberOfGames</th><th data-type="number">EXPR$3</th></tr></thead><tbody><tr><td>p1</td><td>2000</td><td>10</td><td>10</td></tr><tr><td>p1</td><td>2001</td><td>15</td><td>10</td></tr><tr><td>p1</td><td>2002</td><td>12</td><td>10</td></tr><tr><td>p2</td><td>1990</td><td>120</td><td>120</td></tr><tr><td>p2</td><td>1991</td><td>124</td><td>120</td></tr><tr><td>p3</td><td>2006</td><td>30</td><td>30</td></tr><tr><td>p3</td><td>2007</td><td>25</td><td>30</td></tr><tr><td>p3</td><td>2009</td><td>20</td><td>30</td></tr><tr><td>p3</td><td>2010</td><td>15</td><td>30</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pinot.apache.org/release-1.3.0/configuration-reference/functions/first_value.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
