Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
vignesht50
Yak Posting Veteran
82 Posts |
Posted - 2014-02-19 : 09:29:35
|
Hi,This is my table structure --=====create table calculate(ID int identity (1,1),PreviousYear_Profit float not null,)insert into calculate values (12500)insert into calculate values (22700)insert into calculate values (18500)insert into calculate values (25800)--======I want to calculate variance and expected output isID PreviousYear PriorVersion Variance1 12500 sum(PreviousYear) PreviousYear-PriorVersion2 22700 sum(PreviousYear) PreviousYear-PriorVersion3 18500 sum(PreviousYear) PreviousYear-PriorVersion4 25800 sum(PreviousYear) PreviousYear-PriorVersionI don't have PriorVersion and Variance columns.PriorVersion will be like sum(PreviousYear)Variance will be (PreviousYear - PriorVersion)I can query if I have column, since I don't have these two column how could I possibly achieve the output using my existing table schema. Can anyone assist me in this. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2014-02-20 : 00:26:26
|
if you dont have those columns how do you get values for it? does it come from user input or another table?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|