🟢 Repeat: Window Functions Speed Round
Without looking, write the window clause for:
- Rank employees by salary within each department (no gaps for ties)
- Get the previous month's revenue
- Running total of sales ordered by date
Answers:
1. DENSE_RANK() OVER (PARTITION BY department ORDER BY salary DESC)
2. LAG(revenue) OVER (ORDER BY month)
3. SUM(sales) OVER (ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)