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

建表语句:

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中怎么写好呢?

阅读 2.3k
1 个回答

可以尝试这样写:

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

结果如下:

image

推荐问题
logo
101 新手上路
子站问答
访问
宣传栏