Returns the first value in the window frame for each row.
Same as input expressionDiperbarui: 13 Jun 2026FIRST_VALUE(expression) OVER ([PARTITION BY partition_expression] ORDER BY sort_expression [frame_clause])Column or expression whose value is retrieved
Divides data into groups
Determines the order for identifying the first value
1 SELECT 2 symbol, 3 date, 4 price, 5 FIRST_VALUE(price) OVER (PARTITION BY symbol ORDER BY date) as opening_price, 6 price - FIRST_VALUE(price) OVER (PARTITION BY symbol ORDER BY date) as change_from_open 7 FROM `project.dataset.stock_prices`;
Compares the current price against the opening price.
| symbol | date | price | opening_price | change_from_open |
|---|---|---|---|---|
| GOOG | 2024-01-01 | 100 | 100 | 0 |
| GOOG | 2024-01-02 | 105 | 100 | 5 |
| GOOG | 2024-01-03 | 103 | 100 | 3 |
1 SELECT 2 customer_id, 3 order_date, 4 amount, 5 FIRST_VALUE(order_date) OVER (PARTITION BY customer_id ORDER BY order_date) as first_order_date 6 FROM `project.dataset.orders`;
Retrieves the first order date for each customer.
Sudah paham FIRST_VALUE? Latih langsung di browser
Latihan interaktif, langsung di browser.