Select * from tb a where (Select count(*) from tb where type=a.type and score>=a.score)<=2
Select distinct Type,Score From (select Type,score,dense_rank() OVER (Partition by Type Order by Score desc ) as CC From ta ) a Where a.CC <=2
select distinct Type,score From (select Type,Score, dense_rank() OVER ( Partition By Type Order by Score desc ) as CC From tb ) a where a.CC <=2