如何取一天内time最早和最晚时间的volume差值?

想取一天内time最早和最晚时间的volume差值,group by SecurityID。请问在dolphindb中怎么写好呢?

建表语句:

time = take(10:10:00.300+1..30*300, 200)
tradeMoney = double(take(1..100, 200))
SecurityId = take(`A, 100) join take(`B, 100)
volume = take(1..300, 200)
t = table(time,tradeMoney, SecurityId,volume)


表结构如下:

attachments-2021-04-XkIrkcCt608959a219e2f.png

请先 登录 后评论

1 个回答

Xinhai Tang

可以尝试一下下面的查询语句,看是否满足要求:

select last(volume) - first(volume) as differVolume from t group by SecurityId

结果:

attachments-2021-06-huIpSYRW60d53cd8ce62d.png

请先 登录 后评论