Rank 获取排序的序号
Select *,RANK() over (partition by 分组列名 order by 排序列名) as rn from [Table]
例如:获取按…分组的按…排序的每组的前2条记录
select Table1.* from
(
select *,RANK()
over (partition by a.列1,a.列2, order by a.列3) as rn
from Table1
) as Table2
where rn < 3