In article we will explain how to write a MySQL query to find the highest salary from each department from the employees table.
Find the highest salary from each department
Let’s create a simple example of employees table. We will populate this table with id, name, salary and department of employees.
SELECT * FROM employees;
The following MySQL statement find the maximum salary from each department, you will be required to use the GROUP BY clause with the SELECT query.
SELECT department, MAX(salary) FROM employees GROUP BY department ORDER BY MAX(salary) DESC;