Select MIN MAX

The MIN() function returns the smallest value of the column.

The MAX() function returns the largest value of the column.

 SQL Select MIN() Syntax:

SELECT MIN(Column1)

FROM Table_Name

WHERE condition;

SQL Select MAX() Syntax:

SELECT MAX(Column1)

FROM Table_Name

WHERE condition;

Example:

Lets select the MIN and MAX OrderID from the Orders table.

OrderID ProductID EmployeeID OrderDate CustomerID
10 2 1 9/9/2009 2
11 3 2 1/9/2009 3
12 4 1 3/9/2009 4
13 1 3 9/9/2010 5
14 3 1 9/30/2009 3
15 5 2 6/12/2009 1
16 3 4 4/9/2009 6

SELECT MIN(OrderID)
FROM Orders

Results:

OrderID
10

SELECT MIN(OrderID)
FROM Orders


Results:

OrderID
16
Previous
Previous

Select TOP

Next
Next

Select Count, AVG, SUM