如何获取KDB中当天最高报价的时间?

huangapple go评论50阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年3月31日 21:08:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75898928.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定