想取一天内time最早和最晚时间的volume差值,group by SecurityID

JasonT
  • 1.5k

建表语句:

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)

表结构如下:

image.png

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

回复
阅读 827
1 个回答
✓ 已被采纳

可以尝试这样写:

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

结果如下:

image