All Functions
WHERE Clause
HAVING Clause
GROUP BY Clause
FUNCTION: MAX
SELECT MAX(field) AS [expression]
FROM table
[WHERE ...]
[GROUPBY ...]
[HAVING ...]
The
MAX
function is one of the aggregate functions that are used to calculate statistical information for a specified numeric field in a query. The other aggregate functions are:
AVG, COUNT, MIN, STDEV, STDEVP, SUM, VAR, VARP
. Note that all of these functions return a single value.
The
MAX
function simply finds the highest, or maximum, value in a field.
This code finds the longest hospital stay by MediCare patients over the age of 65 and stores that information in MaxStay.
SELECT MAX(DaysInHospital) AS [MaxStay]
FROM MediCarePatients
WHERE age > 65
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information