Sql Server 根据条件查找多条数据中最大值的详细记录
--(正常效果) select l.* from loadCurveSampling l left join Meter m on l.meter_id=m.Meter_ID --聚合当天最大值数据记录 合并查询(聚合效果) select l.* from loadCurveSampling l, (select meter_id,MAX(DT) DT from LoadCurveSampling where CONVERT(varchar(10), DT, 120)='2018-10-29' group by meter_id)b left join Meter m on b.meter_id=m.Meter_ID where l.meter_id=b.meter_id and l.DT=b.DT
效果如下: