Bite-Sized Microlearning Feed

SQL Reels Pro

Scroll tips in 30 seconds!
Window Functions
Duration: 35s

Understanding ROW_NUMBER() Window Functions

Window functions calculate metrics across rows linked to the current record. ROW_NUMBER() sequentially indexes partition rows. Try it to rank employee salaries within each department!

SELECT name, department_id, salary, ROW_NUMBER() OVER (PARTITION BY department_id ORDER BY salary DESC) as salary_rank FROM employees;...