What does the following query do? SELECT id, salary, ROW_NUMBER() OVER (PARTITION BY dept ORDER BY salary DESC) AS rn FROM employees QUALIFY rn = 1
Key points
- The query uses the PARTITION BY clause to group employees by department
- The ROW_NUMBER() function assigns a unique ranking to each employee based on salary
- The QUALIFY clause filters the results to only include employees with a ranking of 1
Ready to go further?
