我有以下疑问:
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)
我想要的结果是每个符号的权重除以权重列中的最大权重。当我按我的方式尝试时,我只收到一行结果。我到底做错什么了?
最佳答案
必须使用子查询和MAX
作为除数,例如:
select ema.weight*1.0/(select max(weight) from #t ema2)
from #t ema
关于mysql - 计算柱(重量/最大(重量)),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36930145/