select max salary in sql code example
Example 1: how to find max and min salary in sql
SELECT MAX(salary), MIN(salary) FROM employees;
Example 2: second max salary in sql
SELECT MAX(SALARY) 'SECOND_MAX' FROM EMPLOYEES
WHERE SALARY <> (SELECT MAX(SALARY) FROM EMPLOYEES);
Example 3: how to find max and min salary in sql
SELECT MAX(SALARY) FROM EMPLOYEES
UNION
SELECT MIN(SALARY) FROM EMPLOYEES;
Example 4: first max salary in sql
SELECT first-name
FROM employees
WHERE salary = (SELECT MAX(salary) FROM employees);
Example 5: sql highest salary by location
SELECT e.ename, e.sal, e.deptno, d.loc
FROM emp e
JOIN dept d
ON e.deptno = d.deptno
WHERE e.sal in
(
select max(sal)
from emp
group by deptno
)
Example 6: max 3 salary in sql
SELECT salary, first_name, last_name FROM employees
ORDER BY salary DESC LIMIT 3;