因为使用到了 group by,需要搭配聚合函数使用,DolphinDB提供了 toArray 函数搭配 group by 语句使用,toArray可以将 group by 分组的数据存储成数组向量的一行,便于直接查看该分组下的所有数据。
我在DolphinDB中使用下面的语句查询数据,使用到了arrayVector创建向量
bars=select first(sx), last(sx), first(sx)-last(sx)+1 as window, last(lastprice) as o, max(lastprice) as h, min(lastprice) as l, first(lastprice) as c, arrayVector([size(lastprice)], lastprice) as lastprice_arr from ticks group by bar(sx_desc,barsize,closed='right')
但是却提示我需要用toArray,修改成下面的语句就可以通过:
bars=select first(sx), last(sx), first(sx)-last(sx)+1 as window, last(lastprice) as o, max(lastprice) as h, min(lastprice) as l, first(lastprice) as c, toArray(lastprice) as lastprice_arr from ticks group by bar(sx_desc,barsize,closed='right')
是因为select语句中只能使用toArray而不能用arrayVector吗