原文:SQL 分組后獲取其中一個字段最大值的整條記錄

方法一: 效率最高 select from test as awhere typeindex select max b.typeindex from test as bwhere a.type b.type 方法二: 效率次之 selecta. from test a, select type,max typeindex typeindex from test group by type bwh ...

2019-11-21 10:28 0 388 推薦指數:

查看詳情

SQL 分組獲取其中一個字段最大值整條記錄

--有id,name,createDate的一張表testTable--根據name分組獲取每組中createDate最大的那條記錄整條)查詢出來---------------------------------------------- 創建一張表,語句如下: CREATE TABLE ...

Fri Jun 23 17:06:00 CST 2017 0 6570
SQL 分組獲取每組中最大值

場景:sql server 2008 目標: select COUNT(*) from ID group by code 產生code列唯一的3行數據,並顯示最小的D列數據 方案1: select code,MIN(D)from ID group ...

Fri Aug 04 01:35:00 CST 2017 0 1175
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM