Sql语句groupBY分组后取最新一条记录的SQL
一、问题
groupBY分组后取最新一条记录的SQL的解决方案。
二、解决方案
select Message,EventTime from PT_ChildSysAlarms as a where EventTime = (select max(b.EventTime) from PT_ChildSysAlarms as b where a.PtName = b.PtName ) group by Message,EventTime order by EventTime desc
宋兴柱:转载内容,请标明出处,谢谢!源文来自 宝贝云知识分享:https://www.dearcloud.cn