I have a simple table with dates a (stock) prices. I have to do a bunch of operations with this data and I was wondering how much I can do in the database before php handles everything.
This some sample data:
DATES DAYS SUMS
3/1/2011 35
2/28/2011 34
2/25/2011 31
2/24/2011 30
2/23/2011 29 159
2/22/2011 28 152
2/18/2011 24 142
2/17/2011 23 134
2/16/2011 22 126
2/15/2011 21 118
2/14/2011 20 110
2/11/2011 17 103
2/10/2011 16 96
2/9/2011 15 89
2/8/2011 14 82
2/7/2011 13 75
2/4/2011 10 68
2/3/2011 9 61
2/2/2011 8 54
2/1/2011 7 47
1/31/2011 6 40 ...
1/28/2011 3 33 (3+6+7+8+9)
1/27/2011 2 26 (2+3+6+7+8)
1/26/2011 1 19 (1+2+3+6+7)
Dates are in the database, I want the days column to be created with my select statement. It represents the number of days + 1 since the first selected date. The sums column is the sum of the current DAY value plus the next five days.
Is it possible to do something like this with a select statement in MySQL?
I'll really appreciate your help!