一、问题
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
一、问题
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