There are three field name , salary, department in a table.
how can we fetch the top 2 salary in each department employee ?
How to fetch top 2 record through group by
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Satyapriya NayakRank #47 · 31.5K reputationPosted May 28, 2012, 9:39 AM EDT
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