Test yourself under real exam conditions: 50 timed questions, 60 on the clock, pass mark 70%%. Instant score with a full review of everything you got wrong. Free — no account needed.
Exam details
SUM(amount) OVER (PARTITION BY user_id ORDER BY ts ROWS UNBOUNDED PRECEDING)
ROW_NUMBER: unique sequential.
RANK: same value → same rank, leaves gaps.
DENSE_RANK: same value → same rank, no gaps.
SELECT * FROM (
SELECT *, ROW_NUMBER() OVER (PARTITION BY group_id ORDER BY score DESC) rn
FROM t
) x WHERE rn <= 3;
LAG(price) OVER (PARTITION BY symbol ORDER BY ts)
LEAD(price) OVER (PARTITION BY symbol ORDER BY ts)