On Wednesday 27 December 2006 16:24, Ashley M. Kirchner wrote: >[...] > > I want to display a graph for the last 24 hours by averaging each > hour. Since I get (at most) 60 readings per hour, I need to average > them out to get a number for that hour. Do I have to do this averaging > outside of MySQL or can it be done within? And I would have to do this > for each of the 24 hours I want displayed.
You can average in MySQL. Try something like this: select hour(time) as the_hour, avg(temp_f) as average_temp_f from data where time > now() - interval 24 hour group by the_hour; You'll want to adjust the "where" clause to specify the correct period, of course. Chapter 12 in the reference manual has a bunch of time functions which you might find useful. Hope that helps -Chris -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]