March 12, 2014 at 4:11 am
Hi,
How can I sum the calculated columns.
select [Funding] [Fundings], [Original] [Originals],[Variance] = [Previous_Year]-[Current_Year],[SumValue] = [CurrentYear]/4, [ActualValue] = [Variance] * 0.75,[FinanceYear], [New Value] = [Previous_Year]+[Current_Year] from Finance
March 12, 2014 at 4:26 am
Do you mean something like the query bellow?
select [Funding] [Fundings],
[Original] AS [Originals],
[Variance] = SUM([Previous_Year]-[Current_Year]),
[SumValue] = SUM([CurrentYear]/4),
[ActualValue] = SUM([Variance] * 0.75),
[FinanceYear],
[New Value] = SUM([Previous_Year]+[Current_Year])
from Finance
GROUP BY [Original], [FinanceYear]
If this is not what you meant, pleas give a better explanation to what you need. Also it will help if you'll add a small script that creates the table and inserts data, so we'll be able to check our code.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 12, 2014 at 4:35 am
I need to sum all the columns.
March 12, 2014 at 5:11 am
vigneshkumart50 (3/12/2014)
I need to sum all the columns.
select [Funding] [Fundings],
[Original] AS [Originals],
[FinanceYear],
[SumofAllCol] = isnull(SUM([Previous_Year]-[Current_Year]),0)
+ isnull(SUM([CurrentYear]/4),0)
+ isnull(SUM([Variance] * 0.75),0)
+ isnull(SUM([Previous_Year]+[Current_Year]),0)
from Finance
GROUP BY [Original], [FinanceYear]
like this ?
March 12, 2014 at 5:22 am
Thanks Adi. I misunderstood the query. Now all good, thanks!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply