SQL Subquery Exercises: Display the department ID, full name, salary for highest salary drawar in a department
SQL SUBQUERY : Exercise-54 with Solution
Write a query in SQL to display the department ID, full name (first and last name), salary for those employees who is highest salary drawar in a department.
Sample table: employees
SELECT department_id, first_name || ' ' || last_name AS Employee_name, salary FROM employees a WHERE salary = (SELECT MAX(salary) FROM employees WHERE department_id = a.department_id);
department_id employee_name salary 90 Steven King 24000.00 60 Alexander Hunold 9000.00 100 Nancy Greenberg 12000.00 30 Den Raphaely 11000.00 50 Adam Fripp 8200.00 80 John Russell 14000.00 0 Kimberely Grant 7000.00 10 Jennifer Whalen 4400.00 20 Michael Hartstein 13000.00 40 Susan Mavris 6500.00 70 Hermann Baer 10000.00 110 Shelley Higgins 12000.00
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query in SQL to display the details of departments managed by Susan.
Next: Write a query in SQL to display all the information of those employees who did not have any job in the past.
What is the difficulty level of this exercise?