MAX returns the maximum value from a set of values.
This function ignores NULL values.
This example returns the maximum, or highest, product price.
SELECT MAX(UnitPrice) AS Maximum
FROM Product
| Maximum |
|---|
| 263.50 |
Syntax of the MAX function.
MAX(value)
value -- a number, column, or subquery.
| ORDER |
|---|
| Id |
| OrderDate |
| OrderNumber |
| CustomerId |
| TotalAmount |
SELECT MONTH(OrderDate) AS 'Month',
MAX(TotalAmount) AS 'Max Order Amount'
FROM [Order]
WHERE YEAR(OrderDate) = 2013
GROUP BY MONTH(OrderDate)
| Month | Max Order Amount |
|---|---|
| 1 | 11493.20 |
| 2 | 5793.10 |
| 3 | 10495.60 |
| 4 | 10588.50 |
| 5 | 10191.70 |
![]() |
|
| PRODUCT |
|---|
| Id |
| ProductName |
| SupplierId |
| UnitPrice |
| Package |
| IsDiscontinued |
| SUPPLIER |
|---|
| Id |
| CompanyName |
| ContactName |
| City |
| Country |
| Phone |
| Fax |
SELECT S.CompanyName,
MAX(UnitPrice) AS 'Highest Price'
FROM Product P
JOIN Supplier S ON S.Id = P.SupplierId
GROUP BY S.CompanyName
| CompanyName | Highest Price |
|---|---|
| Aux joyeux ecclésiastiques | 263.50 |
| Bigfoot Breweries | 18.00 |
| Cooperativa de Quesos 'Las Cabras' | 38.00 |
| Escargots Nouveaux | 13.25 |
| Exotic Liquids | 19.00 |
![]() |
|