如何方便地计算去年同期价格增长率?

目前通过关联,然后两列相除,感觉比较低效,有没有比较方便的办法?

attachments-2022-07-OqdQFWWR62ce428b41fcf.jpg

请先 登录 后评论

1 个回答

Juntao Wang

示例代码:

t = table(2022.07.04T00:00:00 2021.07.04T00:00:00 2022.07.04T00:00:00 2021.07.04T00:00:00 as time, `A`A`B`B as sym, 1.0 2.0 3.0 4.0 as openPrice)

def groupByTime(time) {
	return substr(string(time), 5)
}
select time, sym, openPrice, ratios(openPrice) - 1 as ratios from t context by sym, groupByTime(time) as time csort time
请先 登录 后评论