Returns the maximum value in the expression.
MAX([ALL | DISTINCT] expression)
Returns a value same as expression.
Important Distinct aggregates, for example AVG(DISTINCT column_name), COUNT(DISTINCT column_name), MAX(DISTINCT column_name), MIN(DISTINCT column_name), and SUM(DISTINCT column_name), are not supported when using CUBE or ROLLUP. If used, Microsoft® SQL Server™ returns an error message and cancels the query.
MAX ignores any null values.
For character columns, MAX finds the highest value in the collating sequence.
This example returns the book with the highest (maximum) year-to-date sales.
USE pubs
GO
SELECT MAX(ytd_sales)
FROM titles
GO
Here is the result set:
-----------
22246
(1 row(s) affected)
Warning, null value eliminated from aggregate.