Jump to content

Recommended Posts

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']);
}

Link to comment
https://forums.phpfreaks.com/topic/242122-statistics-from-last-30-days/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.