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

IDTitlePriceDescription
1Learn SQL20Learn SQL language
2Learn MySQL22Learn MySQL language
3HTML book17Learn HTML
4Learn PHP20Introduction to PHP
5Learn PHP20PHP 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

Pricemax_price
2020