27,579
社区成员
发帖
与我相关
我的任务
分享
select * from #tmp a where (select count(1) from #tmp where type=a.type and grade>a.grade)<2 order by [type]
name type grade
---------- ---------- ----------
A com 98
B com 82
C eng 82
A eng 92
A math 85
(5 行受影响)