英文:
How do I get the time of the highest quote of the day in KDB?
问题
我试图从表q中提取max m对应的t。
我的查询是:
select from q where (t.date,m) in (select max m by t.date from q)
这在in部分给我一个'length'错误。我确定我的查询不正确,但我不确定正确的方式是什么。
如何提取max m按照t.date的完整行?
英文:
I've got a table q:
t                             ap     bp     s    m
--------------------------------------------------------
2023.01.03D09:29:00.527999180 130.55 130.51 0.04 130.53
2023.01.03D09:29:00.528127764 130.54 130.51 0.03 130.525
2023.01.03D09:29:00.528406582 130.54 130.51 0.03 130.525
2023.01.03D09:29:00.532340845 130.54 130.51 0.03 130.525
2023.01.03D09:29:00.534640830 130.54 130.51 0.03 130.525
2023.01.03D09:29:00.560375666 130.55 130.51 0.04 130.53
2023.01.03D09:29:01.856393774 130.55 130.51 0.04 130.53
I'm trying to extract the t for max m from q.
My query is:
select from q where (t.date,m) in (select max m by t.date from q)
This gives me 'length error on the in. I'm sure my query isn't right, but I'm not sure what the 'right' way to do it is.
How do I extract the complete row with the max m by t.date?
答案1
得分: 5
你想要 fby
select from q where m=(max;m)fby([]`date$t)
请注意,如果相同的最大价格重复,这可能会返回每个日期多于一行。
英文:
You want fby
select from q where m=(max;m)fby([]`date$t)
Note that this may return more than one row per date if the same max price repeats
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论