【发布时间】:2021-12-09 17:37:36
【问题描述】:
我目前在 Linux 上运行 QuestDB 6.1.2。如何从表中获取具有最大值的行?我在大约 500 万行的测试表上尝试了以下操作:
select * from table where cast(timestamp as symbol) in (select cast(max(timestamp) as symbol) from table );select * from table inner join (select max(timestamp) mm from table ) on timestamp >= mmselect * from table where timestamp = max(timestamp)select * from table where timestamp = (select max(timestamp) from table )
其中 1 正确但运行时间约为 5 秒,2 正确且运行时间约为 500 毫秒,但查询看起来不必要地冗长,3 编译但返回一个空表,4 语法不正确,尽管 sql 通常是这样做的
【问题讨论】:
标签: questdb