赞
踩
假设有以下表格【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)
转载于:https://blog.51cto.com/dengshuangfu/2401461
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。