速度快一点的语句
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