gpt4 book ai didi

MySQL SELECT 仅当值比下一个最高值高 XXX 时

转载 作者:行者123 更新时间:2023-11-30 01:20:39 25 4
gpt4 key购买 nike

我想在 MySQL 表(unix 时间戳)中选择一个字段,仅当它比下一个最高值大 7200 时。如何做到这一点?

我的意思是这样的:

从寄存器中选择 id,其中时间比下一次时间大 7200?

表寄存器:id (int_8)、时间(int_11)、描述(text)

示例:

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)

关于MySQL SELECT 仅当值比下一个最高值高 XXX 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18585844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com