Hi I have some data I need to calculate daily usage by customer.
I need this so I can export to excel for further work to be done on it.
My data in my table looks like this.
ID,CustomerNumber, Date,Reading
1,1,1/1/2010,57162.312
2,1,1/2/2010,57219.9984
3,1,1/3/2010,57269.304
4,1,1/4/2010,57358.8864
5,1,1/5/2010,0
6,1,1/6/2010,57542.9976
7,2,1/1/2010,3686.015
8,2,1/3/2010,3742.465
9,2,1/5/2010,0
10,2,1/6/2010,3846.456
Some days might be missing or 0 so that makes it a bit difficult for me. But I need to calculate the daily usage which would be the reading minus the day before's reading if its a negative number I need it to return 0 not a negative number. It would then need to calculate the usage on the last reading > 0 I have a few thousand records to calculate and several hundred customers.
In this example it should return
CustomerNumber,Date,Usage
1,1/2/2010,57.6864
1,1/3/2010,49.3056 ect....
When it hits a 0
1,1/5/2010,0
1,1/6/2010,184.1112
and so when it get to next customer it needs to then calculate the usage for them and so on.
Thanks for the help!