普通的升降频需求可以用 interval 函数实现,但是由于当前场景是 weekEnd,而 interval 的 ‘w’ 精度仅仅是按 7 天做划分。可以使用 transFreq 进行分组:
select
last(tradetime) as tradetime,
last(securityid) as securityid,
first(open) as open,
max(high) as high,
min(low) as low,
last(close) as close,
sum(vol) as vol,
sum(val) as val
from t group by securityid, transFreq(tradetime, "W")