On this page
Kater SQL Functions Windows
KATER__FIRST_VALUE
The value on the first row of its partition, in the OVER's order.
Family: Windows
Syntax
KATER__FIRST_VALUE(field) OVER ([PARTITION BY ...] ORDER BY ...)Arguments
| Argument | Description |
|---|---|
field | The value it reads on each row: a field, or a measure, such as orders.sum__amount. |
Returns
A value of the field’s own type. The field menu writes the @format of the field it reads beside it, or @format number(2) where that field has none and can have decimals.
Usage notes
- Write
OVER (ORDER BY ...), and addPARTITION BYto start again for each group. It writes its own frame, so itsOVERtakes noROWSorRANGE. - It reads the whole partition, so each row gets the same first value.
Example
This Sandbox query reads the sample shop’s orders. The table shows the rows that Kater gave.
SELECT orders.order_month AS "Order Month", EVAL(orders.sum__quantity) AS "Units", CUSTOM_CALCULATION( 'first_value__sum__quantity', KATER__FIRST_VALUE(orders.sum__quantity) OVER (ORDER BY orders.order_month) ) AS "Units First Month"FROM kater_dataset.orders AS ordersWHERE KATER__IS_ON_OR_AFTER(orders.order_date, DATE '2026-05-01')GROUP BY orders.order_monthORDER BY 1| Order Month | Units | Units First Month |
|---|---|---|
| 2026-05-01 | 441 | 441 |
| 2026-06-01 | 403 | 441 |
| 2026-07-01 | 438 | 441 |
| 2026-08-01 | 454 | 441 |
| 2026-09-01 | 442 | 441 |
Compiles to
FIRST_VALUE(orders.sum__quantity) OVER ( ORDER BY orders.order_month ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)FIRST_VALUE(orders.sum__quantity) OVER (ORDER BY orders.order_month)