Hello,
Lets say, i have the following table
| start | end | activity
+---------------------+---------------------+---------
| 2010-07-26 09:10:00 | 2010-07-26 09:21:00 | 6
| 2010-07-26 09:35:00 | 2010-07-26 09:47:00 | 5
| 2010-07-26 10:05:00 | 2010-07-26 10:45:00 | 5
| 2010-07-26 10:50:00 | 2010-07-26 11:22:00 | 6
| 2010-07-26 13:15:00 | 2010-07-26 13:43:00 | 7
| 2010-07-26 14:12:00 | 2010-07-26 14:55:00 | 2
I want to combine the small time spans, getting the average minutes with activity per hour. Something like that:
| start | minutes_activity | avg_activity
+---------------------+---------------------+---------
| 2010-07-26 09:00:00 | 42 | {avg value}
| 2010-07-26 10:00:00 | 50 | {avg value}
| 2010-07-26 11:00:00 | 22 | {avg value}
| 2010-07-26 13:00:00 | 28 | {avg value}
| 2010-07-26 14:00:00 | 43 | {avg value}
Note that some records can have activity minutes in two hours, i.e 10:50:00 - 11:22:00. In this case, 10 minutes should be added to 10:00 and 22 minutes to 11:00.
A solution, be it MySql, PHP or both is appreciated.
Thank you advance.