digital_priest Posted July 16, 2011 Share Posted July 16, 2011 I'm trying to get the average and the standard deviation of several different selections of entries over several date ranges. The code below is what I've come up with, but I'm getting an error that AVE is not a function for my database. Am I using AVE wrong? Thanks for your help! $day = array(30, 60, 90, date('z')); $weight_stats = array(); foreach ($day as $days) { $ave_vol_sql = "SELECT AVE(weight) as ave_weight, STDDEV_POP(weight) as dev_weight FROM metrics_weight_height_bmi WHERE date_measured BETWEEN CURDATE() - INTERVAL ".$days." DAY AND CURDATE()"; $ave_vol_results = mysql_query($ave_vol_sql) or die(mysql_error()); $ave_vol = mysql_fetch_assoc($ave_vol_results); $weight_stats[$days] = array(ave => $ave_vol['ave_weight'], vol => $ave_vol['dev_weight']); } Quote Link to comment https://forums.phpfreaks.com/topic/242122-statistics-from-last-30-days/ Share on other sites More sharing options...
fenway Posted July 16, 2011 Share Posted July 16, 2011 You mean AVG(), not AVE(). Quote Link to comment https://forums.phpfreaks.com/topic/242122-statistics-from-last-30-days/#findComment-1243485 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.