SQL query to display 2nd highest salaried employee details. And may ask for nth highest code example
Example 1: n highest salary in sql
SELECT salary FROM Employee ORDER BY salary DESC LIMIT N-1, 1
Example 2: sql highest salary by location
/* 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
)