Q1. How do window functions differ from `GROUP BY` aggregation?
Window functions compute a value per row while still returning every individual row, rather than collapsing rows into one per group Window functions can only be used with `COUNT` They're functionally identical to `GROUP BY` Window functions must always sort the entire table first
Q2. What does the `PARTITION BY` clause do in a window function?
Divides rows into groups the window function is computed independently within, without collapsing them into one row per group Physically partitions the table on disk Filters out rows outside the partition Sorts the entire result set
Q3. What's the difference between `RANK()` and `DENSE_RANK()` when there's a tie?
`RANK()` leaves a gap in the ranking after a tie; `DENSE_RANK()` doesn't They always produce identical results `DENSE_RANK()` leaves gaps, `RANK()` doesn't `RANK()` only works with numeric columns
Q4. What does `LAG(column, 1)` return for a given row?
The value of `column` from the previous row within the window ordering The value from the next row The maximum value seen so far The average of all rows in the partition