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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 getting previous months data for calculation

Author  Topic 

Vishakha
Starting Member

40 Posts

Posted - 2006-12-17 : 06:05:38
I have 12 rows in my table, indicating each month of the year.
I need to output an aggregate column for each row which is the sum of previous month's i.e rows data.

Any idea how can I do this.

Table structure
jan val01 val02
feb val11 val12
.
.
.
dec val.. val..

I want the output as

jan val01 val02 -
feb val11 val12 (val01 + val02)
mar val21 val22 (val11 + val12)
apr val31 val32 (val21 + val22)
...

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-12-17 : 10:38:28
Does your table have any Identity column? primary key?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Vishakha
Starting Member

40 Posts

Posted - 2006-12-17 : 11:29:48
it has a month column for each month
actually it is a view that I have created.
and view has one column for month.
Go to Top of Page
   

- Advertisement -