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)
 Calculate daily values by comparing 2 MTD values

Author  Topic 

caseycasper
Starting Member

1 Post

Posted - 2005-05-09 : 13:37:05
Hi - I am creating a view which will have a date, MTD Sales, and Daiy Sales column. The Date and MTD Sales values will be pulled from a table, and Daily Sales will be calculated off of the MTD sales values - today's MTD Sales minus previous day's MTD sales, except for the 1st day of each month, for that the Daily Sales value will be equal to the day's MTD Sales

So it will be like this:

Date MTD Sales Daily Sales
---- ----------- ------------
5/1/2005 100 100
5/2/2005 150 50
5/3/2005 130 -20
5/4/2005 190 60
.
.
.
.
6/1/2005 100 100
6/2/2005 220 120
6/3/2005 150 -70
.
.
.

Note that it is the Daily Sales field that we need to calculate, not the MTD Sales (so it's not like we are calculating a running total of sales here)

Any advise would be greatly appreciated!! Thanks!
   

- Advertisement -