gpt4 book ai didi

mysql - 计算列(重量/最大(重量)

转载 作者:可可西里 更新时间:2023-11-01 09:02:36 27 4
gpt4 key购买 nike

我有以下查询:

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 行结果。我到底做错了什么?

最佳答案

你必须使用 MAX 作为除数的子查询,比如:

select ema.weight*1.0/(select max(weight) from #t ema2)
from #t ema

关于mysql - 计算列(重量/最大(重量),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36930145/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com