Первая максимальная зарплата в SQL
SELECT first-name
FROM employees
WHERE salary = (SELECT MAX(salary) FROM employees);
Obedient Ocelot
SELECT first-name
FROM employees
WHERE salary = (SELECT MAX(salary) FROM employees);
SELECT MAX(SALARY) 'SECOND_MAX' FROM EMPLOYEES
WHERE SALARY <> (SELECT MAX(SALARY) FROM EMPLOYEES);
/* Highest salary by Department/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
)
select max(salary), dept_id from employee where salary not in(select max(salary) from employee) group by dept_id;