我有两张table。示例数据查询:cmadjprice:
select symbol,close,timestamp from cmadjprice;
ABCD,815.9,2014-10-31
ABCD,808.85,2014-11-03
ABCD,797.4,2014-11-05
ABCD,776.55,2014-11-07
ABCD,800.85,2014-11-10
ABCD,808.9,2014-11-11
ABCD,826.8,2014-11-12
ABCD,856.45,2014-11-13
ABCD,856.65,2014-11-14
bb03表格输出示例查询
select symbol,enter_dt,enter_price,exit_dt,exit_price from bb03 ;
ABCD,2014-10-31,815.90,2018-07-27,1073.60
我正在寻找同一日期的最高收盘价。
select a.symbol, max(a.close) ,a.timestamp from cmadjprice a
inner join BB03 b on a.symbol = b.symbol
where a.timestamp between b.enter_dt and b.exit_dt
group by a.symbol,a.timestamp;
我没有得到输出?请在此期望的输出上提供帮助
ABCD,2014-10-31,815.90,2018-07-27,1073.60,856.65,2014-11-14;
2条答案
按热度按时间t3psigkw1#
我想这就是你需要的:
注意,如果最大关闭值在与给定符号相关的时间戳序列中出现不止一次,则这可能返回多个记录
htzpubme2#
请尝试以下操作: