The SQL Min() function returns the smallest value of an expression.

SQL Min() Function Syntax

SELECT MIN(expression)
FROM tables
WHERE predicates

SQL Min() Function Example

Table: Employees

EmployeeId FirstName LastName Department Salary
203 Grrhh Huus Finance 78000
205 Yrbbg Bcciu Finance 57000
204 Neehhi Iymee Finance 45800
206 Qhvii Kirtsc Finance 62000
303 Aliice Benyu Development 55000
302 Yqfgge Llyqu Development 75000
304 Vvgee Tsk Development 49000

Example 1
We want to know the lowest salary among all employees:

SELECT MIN(Salary) AS "Lowest salary"
FROM Employees

The result will look like:

Lowest salary

Example 2
If we want to select lowest salary for each department, we can use GROUP BY clause:

SELECT Department, MIN(Salary) AS "Lowest salary"
FROM Employees
GROUP BY Department

The result will look like:

Department Lowest salary
Finance 45800
Development 49000

Leave a Comment