There are three field name , salary, department in a table.
how can we fetch the top 2 salary in each department employee ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted May 28, 2012, 1:39 PM
SELECT * FROM
(SELECT
name,department,salary
,dense_rank() OVER ( partition by department ORDER BY salary desc) as ranking
FROM test1) a
WHERE a.ranking <=2
Thanks