怎么获取DolphinDB表中一天的股票最高价时的信息

假设我有如下表以及记录

sym = `C`MS`MS`MS`IBM`IBM`C`C`C$SYMBOL;
price= 49.6 29.46 29.52 30.02 174.97 175.23 50.76 50.32 51.29;
qty = 2200 1900 2100 3200 6800 5400 1300 2500 8800;
timestamp = [09:34:07,09:36:42,09:36:51,09:36:59,09:32:47,09:35:26,09:34:16,09:34:26,09:38:12];
t1 = table(timestamp, sym, qty, price);

如何select可以获取每只股票最高价那条记录。

请先 登录 后评论

1 个回答

Jason Tang - 时序数据库技术支持

可以用context by和top来实现:

select top 1 * from t1 context by sym csort price desc

也可以用atImax函数:

select atImax(price,timestamp ) as time,atImax(price,price ) as price,atImax(price,qty ) as qty from t1 group by sym
请先 登录 后评论