SQL MAX() Function


The SQL MAX() is a function, and return the largest or highest value of a numeric table column from query result.

The SQL MAX() function is supports only numeric column.

It can be used in SQL SELECT statement as well in SQL WHERE clause.


Search Keys

  • sql max function
  • sql max date
  • getmax
  • max in sql
  • max function
  • sql where max date
  • select max id from table
  • sql max of two values
  • sql server select max
  • get max value in sql
  • sql select max value
  • select max value from table

SQL MAX() Syntax

The below syntax is used to select specific column from the specific table.


SELECT MAX(column_name1) FROM table_name;


Sample Database Table - Employee

ID EmpName Designation Dept JoinYear Salary
1 Vidyavathi Database Designer MySQL 2014 15440
2 Harish Karthik Employee HTML 2015 17540
3 Hari Krishnan Manager Oracle 2015 17330.2
4 Sakunthala Web Mining Java 2012 5990.3
5 Hanumanthan Project Lead Java 2012 8510.9
6 Keshavan Mobile Database HTML 2015 16910.2
7 Geetha Big Data Oracle 2013 12290.1
8 Azaghu Varshith Manager Java 2015 15230.8
9 Pandurengan Database Developer Java 2012 19640
10 Varshini Kutty Project Lead C#.Net 2015 4310.2
11 Ranjani Mai Tester HTML 2012 10400
12 Bala Murugan Data Mining MS Access 2014 8300

SQL MAX() Example

The following SQL SELECT statement find the largest or maximum value of "Salary" column from the "Employee" table:


SELECT 
MAX(Salary) As 'Maximum Salary' 
FROM Employee;

The result of above query is:

Maximum Salary
19640

SQL MAX() Example - Using Group By Clause

The following SQL SELECT statement find the highest or maximum salary in all "Dept" column from the "Employee" table:


SELECT 
Dept, MAX(Salary) As 'Maximum Salary' 
FROM Employee 
GROUP BY Dept;

The result of above query is:

Dept Maximum Salary
C#.Net 4310.2
HTML 17540
Java 19640
MS Access 8300
MySQL 15440
Oracle 17330.2

Search Keys

  • sql get maximum value
  • max value group
  • sql max command
  • max keyword in sql
  • sql group max
  • sql query max value
  • sql query max
  • max sql example
  • aggregate query
  • aggregate value
  • aggregate functions in sql
  • sql aggregate functions examples