I have a MySQL database which is used to store power readings, with a reading added once per minute. (i.e. 1,440 readings per day).
time power
---- -----
00:00:00 346
00:01:00 352
00:02:00 247
Using PHP I want to produce a graph from this data, but I don't want 1,440 points on the graph. I might choose to split it into 15 minute chunks (which will give me 96 points). Also, I don't want to simply take every fifteenth value, as this will give misleading results. What I want to do is use an SQL query that returns the data in 15 minutes blocks and gives the power reading as an average.
The output might look something like this:
starttime avgpower
--------- --------
00:00:00 342
00:15:00 490
00:30:00 533
Is there an SQL function that will do this for me? or am I going to have to perform t