On this page
Kater SQL Functions Windows
KATER__DELTA
The value minus the value on the row before.
Family: Windows
Syntax
KATER__DELTA(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 number. NULL on the first row of each partition. 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 counts rows, not calendar periods, so a month with no row is skipped.
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( 'delta__sum__quantity', KATER__DELTA(orders.sum__quantity) OVER (ORDER BY orders.order_month) ) AS "Change"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 | Change |
|---|---|---|
| 2026-05-01 | 441 | null |
| 2026-06-01 | 403 | -38 |
| 2026-07-01 | 438 | 35 |
| 2026-08-01 | 454 | 16 |
| 2026-09-01 | 442 | -12 |
Compiles to
The call compiles to the same SQL on DuckDB and on Snowflake.
orders.sum__quantity - LAG(orders.sum__quantity, 1) OVER (ORDER BY orders.order_month)