Hello all,
I am trying to summarize my data based on a column value. e.g:
My data structure is as follows:
RptMonth Sales
200201 500
200201 200
200202 100
200203 200
200203 500
200301 100
200302 100
200302 50
200306 200
I am trying to write an sql statement which will return one record per month that will include total sales UPTO that month. The result should look like
200201 700
200202 800
200203 1500
200304 1500
200305 1500
.
.
.
200301 1600
200302 1750
200303 1750
200304 1750
200305 1750
200306 1950
Currently I am using a union query which works fine for me, but it requires monthly maitenance. Is there a easier way to achieve the desired results? My database is on SQL Server 2000.
Any help is greatly appreciated!
I am trying to summarize my data based on a column value. e.g:
My data structure is as follows:
RptMonth Sales
200201 500
200201 200
200202 100
200203 200
200203 500
200301 100
200302 100
200302 50
200306 200
I am trying to write an sql statement which will return one record per month that will include total sales UPTO that month. The result should look like
200201 700
200202 800
200203 1500
200304 1500
200305 1500
.
.
.
200301 1600
200302 1750
200303 1750
200304 1750
200305 1750
200306 1950
Currently I am using a union query which works fine for me, but it requires monthly maitenance. Is there a easier way to achieve the desired results? My database is on SQL Server 2000.
Any help is greatly appreciated!