3. What are window functions? Give an example.
MediumSQL
Technical
Show model answer
Window functions compute values across related rows without collapsing them like GROUP BY does. Examples: ROW_NUMBER, RANK, running totals with SUM() OVER, and LAG/LEAD for previous or next values.
Running revenue by day: `SELECT day, revenue, SUM(revenue) OVER (ORDER BY day) AS running_total FROM daily_sales;`