stats

🟢 Repeat: Window Functions Speed Round

Without looking, write the window clause for:

  1. Rank employees by salary within each department (no gaps for ties)
  2. Get the previous month's revenue
  3. 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)