取不同類別的第一條資料

2021-09-06 05:24:02 字數 543 閱讀 4580

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_*****_jean_data )b '這裡是得到乙個臨時表no是自動增加號

select  * from #temptable a where [no]=(select top 1 [no] from #temptable where trim_ref = a.trim_ref) '這裡是自動增加號,來巢狀查詢,得到不同類別的第一條資料

Group By 分組並取第一條資料

mysql 我使用排序進行篩選,保證分組 排序之後我的第一條資料就是我要的資料 select a.code a.type as 班型 max a.num from select from cent ylb numclass group by code,type order by code,num d...

mongodb 分組 得到第一條資料

業務邏輯 控制器每分鐘上報採集資料,現需得到每個控制器的每種採集資料的最近一條資料 效能比較低。分組,得到每個控制器每種採集型別的離當前最近的一條記錄 private static void group if curr.createdate result.createdate string fina...

LINQ分組取出第一條資料

person1 id 1,name test1 person2 id 1,name test1 person3 id 2,name test2 以上list如果直接使用distinct方法進行過濾,仍然返回3條資料,而需要的結果是2條資料。下面給出解這個問題的方法 方法1 distinct 方法中使...