MAX() function in MYSQL by R4R Team

MYSQL MAX() function:
-Basically, MAX() function is return the maximum value of the table or the columns.

Syntax:
SELECT MAX(expression)
FROM table_name
WHERE conditions;

Display all record of table 'employee':

SELECT * FROM employee;

emp_id emp_name department emp_salary
1 Aman D1 34000
2 Ram D2 43000
3 Ramesh D1 20000
4 John D3 65000
5 Sita D1 10000
6 Dinesh D2 15000

Now find maximum salary:

SELECT MAX(emp_salary) FROM employee;

MAX(emp_salary)
65000


Now we display the employee detail which have maximum salary:

SELECT * FROM employee WHERE emp_salary is (SELECT MAX(emp_salary) FROM employee);

emp_id emp_name department emp_salary
4 John D3 65000



Leave a Comment: