Window functions, CTEs & advanced SQL
Window functions and CTEs separate candidates who can answer real business questions from those who can only filter tables.
- ROW_NUMBER, RANK and DENSE_RANK for top-N per group
- LAG / LEAD for period-over-period change
- Running totals and moving averages with frame clauses
- CTEs and subqueries for multi-step logic
- Classic asks: retention, second-highest salary, consecutive days, duplicates
- Self joins and anti joins (NOT EXISTS)
Retention, funnels, gaps-and-islands and deduplication, timed.