xxxxxxxxxx
select name, salary
from (
select name, salary, dense_rank() over (partition by departmentId order by salary desc) ranking
from Employee
) t
where ranking < 4
xxxxxxxxxx
SELECT a.field1, a.field2
FROM (
SELECT field1, field2, ROW_NUMBER() --use RANK() if you want ranking
over (Partition BY field_partition
ORDER BY data_field DESC ) AS Rank
FROM your_table
) a WHERE Rank <= 3 --Row Number you want of each group