|
dhani
Posting Yak Master
132 Posts |
Posted - 2010-08-22 : 22:53:07
|
| hello All,i am in a weired situation,basically what i am trying to do is find out weighted average for meanterm by noofmats(ex 4 mats or 7 mats)i have currency, countrym factorname and date column called IssueDate (out of it i have to get it year2008 , year2009, year 2010) select currency,country, factorname, case datepart(yyyy,getdate()) when 2008 then Sum(convert(float, MeanTerm)) / count(Noofmats) as WeightedAverag else (0) end as Year2008,case datepart(yyyy,getdate()) when 2009 then Sum(convert(float, MeanTerm)) / count(Noofmats) as WeightedAverag else (0) end as Year2009case datepart(yyyy,getdate()) when 2010 then Sum(convert(float, MeanTerm)) / count(Noofmats) as WeightedAverag else (0) end as Year2010group by currency,country,factornameexpect ouput results will beCurrency, country, FactorName, year2008, Year2009, Year2010AUD, AUS, MidWire,35,46,37AUD, AUS, Singale,11,16,3AUD, NZ, MidWire,76,76,87AUD, Singapore, MidWire,15,36,37USD, CAN, Sizzle,315,14,67USD, USA, CAPITAL,323,346,437but i am unable to get what i desire is there anyway to get weighted average by year wise(which is not a column) it needs to be calculate in query iyselfplease help methanks in advancedhani |
|