The MIN() function in SQL is used to find the minimum value in a specified column, and the syntax is MIN(expression). It is used to find the minimum value in a set of values, determine the minimum value for comparison or filtering, ignore NULL values, and can be used in conjunction with other functions and operators.
Usage of MIN() function in SQL
MIN() function is used to find the minimum value in a specified column .
Syntax:
MIN(expression)
Where:
Usage:
MIN() function can be used in the following scenarios:
Example:
-- 查找表 "sales" 中 "price" 列的最小值 SELECT MIN(price) FROM sales; -- 查找每个客户购买的最便宜商品的价格 SELECT customer_id, MIN(price) AS cheapest_product_price FROM sales GROUP BY customer_id;
Notes:
Other options:
The MIN() function has some optional parameters that can be used to further control the behavior of the function:
The above is the detailed content of Usage of min function in sql. For more information, please follow other related articles on the PHP Chinese website!