修改SQL写法如下:
select * from sensor_alarm s ,
(SELECT MAX(si.gmt_create) max_gmt_create,si.s_id FROM sensor_alarm si group by si.s_id ) s2
where s2.s_id = s.s_id AND s2.max_gmt_create = s.gmt_create
ORDER BY s.gmt_create DESC
LIMIT 0,10
修改SQL写法如下:
select * from sensor_alarm s ,
(SELECT MAX(si.gmt_create) max_gmt_create,si.s_id FROM sensor_alarm si group by si.s_id ) s2
where s2.s_id = s.s_id AND s2.max_gmt_create = s.gmt_create
ORDER BY s.gmt_create DESC
LIMIT 0,10