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.heiqu.com/zwszxg.html