取不同类别的第一条数据

select a.* from tb a where val = (select top 1 val from tb where name = a.name)

select row_number()over(order by Size )as RowNum,*from O_OrderWovenLabel 'row_number()over(order by Size )表示得到某一列的行号
Select no=Identity(int,1,1),* Into #temptable From (select * from  View_Get_Paper_JEAN_Data )B '这里是得到一个临时表no是自动增加号
select  * from #temptable A where [no]=(select top 1 [no] from #temptable where Trim_Ref = A.Trim_Ref) '这里是自动增加号,来嵌套查询,得到不同类别的第一条数据

原文地址:https://www.cnblogs.com/yzenet/p/2597862.html