How to Get the Highest Salary of Each Department?
Could you please help me to get the highest salary for each department. If multiple employees having the highest salary in the same department then I need the get oldest employee details(who joined first in the company).
Please use the SQL Query below in order to get the highest salary of department:
SELECT DepartmentID, MAX(Salary)Â FROM Employee Â GROUP BY DepartmentID
Now for Printing the name, you must join the Employee table with Department table using key DepartmentID,
SELECT DepartmentName, MAX(Salary)Â FROM Employee e RIGHT JOIN Department d ON e.DepartmentId = d.DepartmentIDÂ GROUP BY DepartmentName