RSS Feed

SQL MAX()

SQL MAX()

Returns the maximum value in the expression.

Example 1 of SQL MAX()
Selecting Max salary from EMP table:

SELECT MAX(salary) as "Maximum Salary"
FROM EMP;

Example 2 of SQL MAX()
Selecting Max salary for each department:

SELECT Dept, MAX(salary) as "Maximum Salary"
FROM EMP
GROUP BY Dept;


SQL MAX() ignores any null values.

For character columns, SQL MAX() finds the highest value in the collating sequence.

No comments:

Post a Comment