PDA

View Full Version : MYSQL average


soundgod1818
09-03-2009, 04:42 PM
I have a Database that stores the power usage of a server. Every hour the usage is pooled and stored in the database. I have a month day and hour field. I use this database to display the usage of power in a graph for every day of the year.
Here is what I am trying to do is there a way to average this data for the month. For example I wanted to have a graph that has 30 days and every day would be an average for that 24 hour cycle.
I was trying to do this in as little of queries as I can. I know I can have a loop that queries the database for every day of the month.

ckeyrouz
09-03-2009, 04:53 PM
check the usage of avg() method in mysql:

http://www.tizag.com/mysqlTutorial/mysqlavg.php