max salary in sql code example
Example 1: min and max salary and name in sql
SELECT FIRST_NAME , SALARY
FROM EMPLOYEES
WHERE SALARY IN (SELECT MAX(SALARY)AS RESULT FROM EMPLOYEES
UNION
SELECT MIN(SALARY)AS RESULT FROM EMPLOYEES);
Example 2: how to find max and min salary in sql
SELECT MAX(salary), MIN(salary) FROM employees;
Example 3: second max salary in sql
SELECT MAX(SALARY) 'SECOND_MAX' FROM EMPLOYEES
WHERE SALARY <> (SELECT MAX(SALARY) FROM EMPLOYEES);
Example 4: FIND OUT THE NAME HIGHEST SALARY SQL
SELECT FIRST_NAME FROM EMPLOYEES
WHERE SALARY = (SELECT MAX(SALARY) FROM EMPLOYEES);
Example 5: how to get max salary in each department in sql
SELECT firstname, MAX(salary)
FROM department d LEFT OUTER JOIN employee e
ON (d.department_id = e.department_id)
GROUP BY department_id;
Example 6: how to find max and min salary in sql
SELECT MAX(SALARY) FROM EMPLOYEES
UNION
SELECT MIN(SALARY) FROM EMPLOYEES;