SQL Window Functions Interview Guide
SQL Window Functions Interview Guide
Example:
SELECT
employee_id,
department,
salary,
RANK() OVER(PARTITION BY department ORDER BY salary DESC) AS dept_rank
FROM employees;
This gives each employee a rank based on salary within their department.