SQL MIN

SQL MIN

The SQL MIN function returns the minimum value in a select query.

MIN syntax

SELECT MIN(table_column)
FROM table_name;

MIN example

Coder books table

ID Title Price Description
1 Learn SQL 20 Learn SQL language
2 Learn MySQL 22 Learn MySQL language
3 HTML book 17 Learn HTML
4 Learn PHP 20 Introduction to PHP
5 Learn PHP 20 PHP course
SELECT MIN(price) 
FROM coder_books;

Result

17

SELECT price, MIN(price) min_price
FROM coder_books
GROUP BY price
HAVING count(*) > 1;

Result

Price max_price
20 20