2014-03-26 77 views
0

我想用平均EPSF1值超過66,000行來劃分從ticker=7203 JT股權每個EPSF1值進行比較,我不知道如何這兩個查詢值的整體平均

select Date, Ticker,EPSF1 
from tblForecasts 
where EPSF1 is not null 
and Ticker='7203 jt equity' 

select AVG(epsf1) 

回答

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'