Window functions are tested in almost every SQL interview.
Core functions:
- ROW_NUMBER(): Unique row identifiers
- RANK()/DENSE_RANK(): Handle ties differently
- LAG()/LEAD(): Access previous/next rows
- SUM()/AVG() OVER: Running calculations
Syntax pattern:
SELECT column,
ROW_NUMBER() OVER (
PARTITION BY group_col
ORDER BY sort_col
) as row_num
FROM table
Practice: Running totals, rank within groups, gap detection.