Window functions perform calculations across a set of rows (a "window") related to the current row, without collapsing them into a single output row (unlike aggregates with GROUP BY). They enable powerful analytics — running totals, rankings, comparisons to other rows — while keeping each row in the result.
The key difference from GROUP BY
GROUP BY → collapses groups into ONE row each (you lose individual rows)
Window function → computes across related rows but KEEPS every row
→ You get per-row detail AND aggregate/ranking info together.
