速度快一点的语句

weixin_38062043 2017-02-22 10:47:39
select *,(select age from test as o2 where o2.cnm<o1.cnm order by o2.cnm desc limit 1) as pre from test as o1
where age=(select age from test as o2 where o2.cnm>o1.cnm and name=o1.name order by o2.cnm limit 1)
and not exists(select * from test where age<>o1.age and cnm between o1.cnm and DATE_ADD(o1.cnm,INTERVAL 2 hour) and name=o1.name)
group by name;
求同一个name下,age超过两个小时是一个值的数据
cnm是时间列
我写的语句速度慢那,应该怎么写?

please verify my account
...全文
16 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧