Soft technology web class: SQLServer the MIN () function

MIN () function

MIN function returns the minimum value in a column. NULL values ​​are not included in the calculation.

SQL MIN () syntax

	SELECT MIN(column_name) FROM table_name

NOTE: MIN and MAX text columns may also be used to obtain the highest or lowest value in alphabetical order.

SQL MIN () example

We have the following "Orders" table:

O_Id OrderDate OrderPrice Customer
1 2008/12/29 1000 Bush
2 2008/11/23 1600 Carter
3 2008/10/05 700 Bush
4 2008/09/28 300 Bush
5 2008/08/06 2000 Adams
6 2008/07/21 100 Carter

Now, we want to find the minimum value "OrderPrice" column.

We use the following SQL statement:

	SELECT MIN(OrderPrice) AS SmallestOrderPrice FROM Orders

The result set will look like this:

SmallestOrderPrice
100

Original link: http: //www.sysoft.net.cn/Article.aspx ID = 3735?

Guess you like

Origin www.cnblogs.com/sysoft/p/11576341.html