sql 查询每组最大值
1.第一种方法 查询最大的数据分组之后链表查询select * from Warehouse_Information tinner join(select f.Products_Id,MAX(DATA0) datas from Warehouse_Information f Group by f.Products_Id) k on t.Products_Id=k.Products_Id and k
·
1.第一种方法 查询最大的数据分组之后链表查询
select * from Warehouse_Information t inner join
(select f.Products_Id,MAX(DATA0) datas from Warehouse_Information f Group by f.Products_Id) k on t.Products_Id=k.Products_Id and k.datas =t.DATA0
2.第二种方法 排序方法
select * from
(
SELECT t.*,ROW_NUMBER() over (partition by t.Products_Id order by t.DATA0 desc) numm
FROM Warehouse_Information t where t.DATA0 in (select MAX(f.DATA0)
from Warehouse_Information f Group by f.Products_Id)
) a
where numm=1
更多推荐
已为社区贡献2条内容
所有评论(0)