Window Functions 1: OVER, PARTITION BY, ROW_NUMBER, RANK and Top-N per Group
A window function computes like GROUP BY but does not collapse rows; it writes the result next to each row. We show OVER and PARTITION BY, how ROW_NUMBER, RANK, DENSE_RANK and NTILE differ on ties, why they cannot appear in WHERE, top-N per group with a CTE, the tie decision, and safe duplicate removal with ROW_NUMBER on Bookstore data with real output.
8 Nov 2026
·
14 min
·
6