我有以下查询:计算列(重量/ MAX(重量)
select ema.es_symbol as symbol, ema.score as score, ema.weight as weight, rsi.relative_strength_index as relative_strength_index
from ema_score ema, relative_strength_index rsi inner join
(select rsi_symbol, max(rsi_date) as maxDate from relative_strength_index group by rsi_symbol) rsiDate
on rsi.rsi_symbol = rsiDate.rsi_symbol
and rsi.rsi_date = rsiDate.maxDate
where ema.es_symbol = rsi.rsi_symbol
and ema.score not in (0,1,10,11)
and rsi.relative_strength_index not in (0,100);
我想添加一个计算列像下面的一个作为最终列:
ema.weight/max(ema.weight)
的我想要的结果是每个符号重量除以权重列中的最大权重当我按照自己的方式尝试时,我只收到1行结果我究竟在这里做了什么错误
没有group by子句的任何聚合函数(如max())会将结果集合折成单个记录。 – Shadow
我尝试了一组,但我的计算列收到每行相同的答案。 – ULuFlanders
@ULuFlanders,因为你必须使用子查询作为除数,请检查我的答案。 –