我想将ticker=7203
JT Equity的每个EPSF1值除以EPSF1
行的平均66,000
值,我不知道如何合并这两个查询
select Date, Ticker,EPSF1
from tblForecasts
where EPSF1 is not null
and Ticker='7203 jt equity'
select AVG(epsf1)
答案 0 :(得分:0)
声明变量,将平均值存储在那里,然后在查询中使用它:
declare @avg decimal
select @avg = AVG(epsf1) from tblForecasts
select Date, Ticker,EPSF1 / @avg
from tblForecasts
where EPSF1 is not null
and Ticker='7203 jt equity'