MySQL仅当值高于下一个最高值XXX时才选择
我想在MySQL表unix timestamp中选择一个字段,前提是该字段大于次高值7200。怎么做 我的意思是这样的: 从时间比下一次大7200的寄存器中选择id 表寄存器:id int_8、timeint_11、descriptionContext 例如:MySQL仅当值高于下一个最高值XXX时才选择,mysql,unix,select,timestamp,Mysql,Unix,Select,Timestamp,我想在MySQL表unix timestamp中选择一个字段,前提是该字段大于次高值7200。怎么做 我的意思是这样的: 从时间比下一次大7200的寄存器中选择id 表寄存器:id int_8、timeint_11、descriptionContext 例如: 1, 127586113, This is description 2, 127587399, This is description (NEXT HIGHEST) 3, 127588524, This is description (H
1, 127586113, This is description
2, 127587399, This is description (NEXT HIGHEST)
3, 127588524, This is description (HIGHEST, LET'S SAY EQUAL TO NOW())
如果我正确理解了这个问题,这应该可以解决。请添加您的表结构、示例数据和预期输出。
select id
from registers r
where not exists
(select 1 from registers where time < r.time and time > r.time - 7200)
select id from registers
WHERE time = ( select min(time)
from registers
where time > 7200);