如何实现找到每个股票最高点对应的时间列

怎样返回最高点对应的时间?下面的语句返回是空
select datetime from all where   bondcode='123230.SZ' and  close==max(close)

请先 登录 后评论

1 个回答

veryOrdinary

因为 close==max(close) 是对整个表的数据进行过滤的,如果最大值所在的票不是 '123230.SZ' 那么就会是空,可以拆成两个语句,即先选出票再过滤,更高效的写法是对所有票一起计算,参考如下脚本

t = table(2022.01.01+1..3 as time, `b`b`a as sym, 1.1 1.2 1.3 as id)
select time from t context by sym having id = max(id)

请先 登录 后评论
  • 1 关注
  • 0 收藏,203 浏览
  • Polly 提出于 2024-01-30 16:03