想取一天内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)

表结构如下:

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

attachments-2021-05-iKMMNyT8609523b7e1491.png

请先 登录 后评论

1 个回答

chenweijian

可以尝试这样写:

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

结果如下:

attachments-2021-06-YWZyRCPj60c07bcda469d.png


请先 登录 后评论