sql 分组后取第一条数据
select * from (
select *,ROW_NUMBER() OVER(partition by OrderDate,PackageNo,BatchCode,SortLine order by SortLine) as new_index
from table) t where new_index=1
partition by 表示分组的字段
order by 表示每个分组内的结果集排序
select * from (
select *,ROW_NUMBER() OVER(partition by OrderDate,PackageNo,BatchCode,SortLine order by SortLine) as new_index
from table) t where new_index=1
partition by 表示分组的字段
order by 表示每个分组内的结果集排序