Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Question: Write a SQL query to find the employees who have the highest salary in each department.
Answer: SELECT department, employee_name, salary FROM (SELECT department, employee_name, salary, ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) AS rnk FROM Employee) AS ranked WHERE rnk = 1;
Is it helpful? Yes No

Most helpful rated by users:

©2025 WithoutBook