A query uses ROW_NUMBER() OVER (PARTITION BY dept_id ORDER BY salary DESC). What does this produce?

SQL Data Analyst Hard

SQL Data Analyst — Hard

A query uses ROW_NUMBER() OVER (PARTITION BY dept_id ORDER BY salary DESC). What does this produce?

Key points

  • The function ROW_NUMBER() assigns a unique sequential number to each row
  • PARTITION BY separates the ranking into groups based on dept_id
  • ORDER BY salary DESC arranges the rows in descending order of salary

Ready to go further?

Related questions