The MIN()
function returns the smallest value of the selected column.
Return the lowest price in the products
table:
SELECT MIN(price)
FROM products;
Run Example »
The MAX()
function returns the largest value of the selected column.
Return the highest price in the products
table:
SELECT MAX(price)
FROM products;
Run Example »
When you use MIN()
or MAX()
, the returned column will be named min
or max
by default. To give the column a new name, use the AS
keyword.
Return the lowest price, and name the column lowest_price
:
SELECT MIN(price) AS lowest_price
FROM products;
Run Example »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!