MIN() — Find the Minimum Value
The MIN() function returns the smallest value in a column.
It works with numbers, dates, and text values (alphabetically).
Syntax
SELECT MIN(column) FROM table_name WHERE condition;
Example 1: Minimum Age of Employees
SELECT MIN(age) FROM employees;
This returns the youngest age of any employee.
+----------+
| MIN(age) |
+----------+
| 24 |
+----------+
Example 2: Minimum Age per Department
SELECT department, MIN(age)
FROM employees
GROUP BY department;
This returns the youngest age of employees for each department.
+------------+----------+
| department | MIN(age) |
+------------+----------+
| HR | 24 |
| IT | 24 |
| Sales | 25 |
| Marketing | 29 |
| Finance | 27 |
+------------+----------+
Example 3: First Department Alphabetically
SELECT MIN(department) FROM employees;
This returns the department name that comes first alphabetically.
+-----------------+
| MIN(department) |
+-----------------+
| Finance |
+-----------------+
Tip
MIN()ignoresNULLvalues.- Works with numbers, text, and dates.
The MIN() function helps you find the smallest or earliest value in your data!