Select Min in SQL
? SELECT MIN() in SQL
The MIN() function returns the minimum value from a column in a table. It is used to find the smallest numeric value, earliest date, or minimum string in a dataset.
? Syntax:
SELECT MIN(column_name) FROM table_name WHERE condition;? Examples:
Find the lowest salary in employees table:
SELECT MIN(salary) AS lowest_salary FROM employees;Find the earliest order date:
SELECT MIN(order_date) AS first_order_date FROM orders;Find the minimum product price in a category:
SELECT MIN(price) AS min_price FROM products WHERE category = 'Electronics';? Notes:
Works on numeric, date/time, and string columns.
Returns a single scalar value.
Can be used with
GROUP BYto find minimums per group:
SELECT department, MIN(salary) AS min_salaryFROM employeesGROUP BY department;Want examples combining MIN() with other functions or clauses?