Suppose we have 3 employees in each department.we have total 3 departments . Below is the sample source table
Emp deptno salary A 10 1000 B 10
This will give you 2nd highest salary in each department:
SELECT a.Emp, a.deptno, a.salary FROM Emp a WHERE 1 = (SELECT COUNT(DISTINCT salary) FROM Emp b WHERE b.salary > a.salary AND a.deptno = b.deptno) group by a.deptno