PostgreSQL MIN

PostgreSQL MIN

The PostgreSQL MIN aggregate function returns the minimum value in a select.

MIN syntax

SELECT MIN(table_column)
FROM table_name;

MIN example

Goods table

idgood_typenamedescriptionprice
1ACar_1Car 1 description100
2ACar_2Car 2 description200
3ACar_3Car 3 description100
4BBoat_4Boat 4 description500
5BBoat_5Boat 5 description300
6CTrain_1Train 123 description800
SELECT MIN(price) 
FROM goods;

Result

100

SELECT good_type, MIN(price) min_price
FROM goods
GROUP BY good_type;

Result

good_typemin_price
B300
C800
A100