以下內容僅做備忘
假設有以下表格【FM_ALARM】
RES_ID : 資源的唯一標識
OCCUR_TIME : 發生時間(毫秒時間戳)
SEVERITY : 告警級別
數據會實時變更,我要取出所有數據的最新一條記錄,則可以使用以下SQL
select res_id, severity
from fm_alarm t
where not exists (select 1
from fm_alarm
where t.res_id = res_id
and t.occur_time < occur_time)