单个字段去重并选出每个分组里面的最大值对应的行:
Row_Number去重:
select * from (select *,row_number()over(partition by Servername order by Check_Date desc) Suquence from AuditItem) s where s.Suquence=1
Croup by写法:
select * from [dbo].[AuditItem] where Check_Date in (select Max(Check_Date) from AuditItem group by servername)
原文地址:https://www.cnblogs.com/LC0507/p/11177613.html
时间: 2024-10-19 09:34:13