Jump to content

Statistics from last 30 days


digital_priest

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.