SQL MAX Function
SQL MAX() column functions find the largest value in a column. The data in the column can contain numeric, string, or date/time information. SQL MAX function is used to return the maximum value for the values of a column in a group of rows. NULL values are ignored when using the SQL MAX function. The result of the SQL MAX() function has exactly the same data type as the data in the column.
Example:
The following will return maximum salary paid in employee table:
SELECT MAX(salary)
FROM employee;
Output:
Example 2:
The following SQL MAX function finds the date of birth for youngest employee in the employee table:
SELECT MAX(birth_date)
FROM employee;
Output:
Note: SQL MAX function is used on DATE datatype.
Example 3:
The following SQL MAX function finds the alphabetic max of last name:
SELECT MAX(Last_Name)
FROM employee;
Output:
Note: SQL MAX function is used on CHARACTER datatype.