SQL min() 函数实例

MIN() 函数返回指定列的最小值。

SQL MIN() 语法

SELECT MIN(column_name) FROM table_name;
知识兔

 

演示数据库

在本教程中,我们将使用众所周知的 Northwind 样本数据库。

下面是选自 "Products" 表的数据:

ProductIDProductNameSupplierIDCategoryIDUnitPrice
1Chais1110 boxes x 20 bags18
2Chang1124 - 12 oz bottles19
3Aniseed Syrup1212 - 550 ml bottles10
4Chef Anton's Cajun Seasoning2248 - 6 oz jars21.35
5Chef Anton's Gumbo Mix2236 boxes25

 

SQL MIN() 实例

下面的 SQL 语句从 "Products" 表的 "Price" 列获取最小值:

SELECT MIN(Price) AS SmallestOrderPrice FROM Products;
知识兔
计算机