SQL MAX Function
Syntax
The MAX function in SQL is used to find the maximum value of a column.
-- Find the maximum value in a columnSELECT MAX(column1)FROM table_name;
-- Find the maximum value for each groupSELECT column2, MAX(column1)FROM table_nameGROUP BY column2;Example
-- Find the maximum salary of all employeesSELECT MAX(salary)FROM employees;/* Output:| MAX(salary) ||-------------|| 60000 |*/
-- Find the maximum salary for each departmentSELECT department, MAX(salary)FROM employeesGROUP BY department;/* Output:| department | MAX(salary) ||-------------|-------------|| Sales | 50000 || Marketing | 40000 || HR | 60000 |*/