Sql语句groupBY分组后取最新一条记录的SQL
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
Sql语句groupBY分组后取最新一条记录的SQL
https://www.dearcloud.cn/2019/11/27/20200310-cnblogs-old-posts/20191127-Sql语句groupBY分组后取最新一条记录的SQL/