examples · sql · 9 / 13 · works today
9. Window functions
← SQL examplesworks today
ROW_NUMBER(), RANK(), DENSE_RANK(),
LAG() and LEAD() with
OVER (PARTITION BY ... ORDER BY ...) all execute server-side through the SQL translator.
Only explicit ROWS BETWEEN frame clauses are still rolling out.
per-group ranking
Rank each customer's orders by amount - the canonical window use - runs server-side:
SELECT id, customer_id, amount_cents,
ROW_NUMBER() OVER (
PARTITION BY customer_id
ORDER BY amount_cents DESC
) AS rn
FROM shop.orders
Each row comes back with its rn computed in one pass - no client-side sorting needed.
still rolling out
Explicit ROWS BETWEEN / RANGE frame clauses
(custom windows) aren't wired through SQL yet. If you need one,
tell us - prioritization is driven by real demand.