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 |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-11-02 : 07:47:16
|
David writes "I am not quite sure how to approach this problem. I have data provided to me that is in my mind very hard to work with. The calls handled column is a monthly accumulative total. I want to be able to add a column to my query or table that will subtract the calls_handled total from the previous week. An example would be:I would like to add a new coulumn called "actual_calls". This would be a total that is calculated from calls_handled - the previous weeks called handled. In this case 111 calls hadled would be the first weeks "actual_calls" number of calls. This would not have a previous week to subtract because it is the first week of the month. The second weeks actual calls handled would be 514-111. The third week actual calls handled would be 912-514 etc. The data is provided to me on a weekly basis and there is always a final month end total sent to me on the last day of each month to account for all the data for a given month. Then the whole process starts over for the next month. What is the best approach to calculate what the actual call numbers are for a given week?SQL SERVER 2000Windows 2003date_id person_id calls_handled 20060203 22008 11120060210 22008 51420060217 22008 91220060224 22008 135820060228 22008 151420060303 22008 47620060310 22008 121120060317 22008 185820060324 22008 240220060331 22008 304720060407 22008 68520060414 22008 136120060421 22008 191120060428 22008 224620060430 22008 2421 " |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-02 : 07:51:33
|
Then you will get a negative value for 20060303 and 20060407. Is that correct?Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|