How to find the Nth highest and lowest salary for each department

sanbarasan03
09:09:11
The emp table datas are..

id name deptno salary
1 a 10 16500
2 b 20 7000
1 c 10 12500
2 d 30 17000
1 g 20 15000
2 h 30 10000
1 g 10 5500
2 b 30 25000
1 n 10 9000
2 k 20 35000
1 a 30 16500
2 m 20 7000

from the above table i need the 3rd highest salary for each department no
but i try below but its not working..

select deptno,salary from emp where deptno in (select deptno from emp group by deptno) order by salary desc 2,1;

-thanks and regards










Please Login to post your reply or start a new topic