MySQL Group By Group By Using MIN function

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Assume a table of employees in which each row is an employee who has a name, a department, and a salary.

SELECT department, MIN(salary) AS "Lowest salary"
FROM employees
GROUP BY department;

This would tell you which department contains the employee with the lowest salary, and what that salary is. Finding the name of the employee with the lowest salary in each department is a different problem, beyond the scope of this Example. See "groupwise max".



Got any MySQL Question?