0
如何从尝试的每个设备查询中获取最新记录
select * from Data
where dname = 'abc'
group by did
order by timestamp desc
样本数据
sl emei mname dname did timestamp
66 868997036667 LB abc 52 59.6 2019-09-06 14:51:21.0000000
67 868997036667 LB abc 46 59.3 2019-09-06 15:51:21.0000000
68 868997036667 LB abc 52 58.4 2019-09-06 16:51:21.0000000
69 868997036667 LB abc 46 58.5 2019-09-06 17:51:21.0000000
运
68 868997036667 LB abc 52 58.4 2019-09-06 16:51:21.0000000
69 868997036667 LB abc 46 58.5 2019-09-06 17:51:21.0000000
你可以用row_number()与partition。
select *
from (select sl, emei, mname, dname, timestamp, did
, row_number() over (partition by did order by sl desc) as rn
from Data where dname = 'abc') t1
where t1.rn = 1
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。