1SELECT MAX(SALARY) 'SECOND_MAX' FROM EMPLOYEES
2WHERE SALARY <> (SELECT MAX(SALARY) FROM EMPLOYEES);
1SELECT MAX(SALARY) 'SECOND_MAX' FROM EMPLOYEES
2WHERE SALARY <> (SELECT MAX(SALARY) FROM EMPLOYEES);
3
4
5OR
6
7Here is the solution for nth highest
8salary from employees table
9
10SELECT FIRST_NAME , SALARY FROM
11(SELECT FIRST_NAME, SALARY, DENSE_RANK() OVER
12(ORDER BY SALARY DESC) AS SALARY_RANK
13FROM EMPLOYEES)
14WHERE SALARY_RANK = n;
1SELECT first-name
2FROM employees
3WHERE salary = (SELECT MAX(salary) FROM employees);
1/* Highest salary by Department/Location */
2SELECT e.ename, e.sal, e.deptno, d.loc
3FROM emp e
4JOIN dept d
5ON e.deptno = d.deptno
6WHERE e.sal in
7(
8 select max(sal)
9 from emp
10 group by deptno
11)
1select max(salary), dept_id from employee where salary not in(select max(salary) from employee) group by dept_id;