CodeIgniter Forums
In aggregated without GROUP BY error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: In aggregated without GROUP BY error (/thread-67505.html)



In aggregated without GROUP BY error - doomie22 - 03-01-2017

Hi all,

I have recently updated my local WAMP testing platform to version 3 (I know, bad mistake).  Something that was previously working fine is now coming up with this big error and I really don't know what it means.

This is what is in the controller:

PHP Code:
$data['this_month_uniques'] = $this->Analytics_model->get_month_page_views('0 months'true'unique_hits'); 


This is what is in the model:

PHP Code:
   public function get_month_page_views($month_num$total false$column){
    $pm = (int) date('n'strtotime($month_num));
    $pmy = (int) date('Y'strtotime($month_num)); 
    $this
->db->select('*');
    $this->db->from('analytics_page_views');
    $this->db->where('MONTH(date)'$pm);
    $this->db->where('YEAR(date)'$pmy);
    if ($total == 'true'){
    $this->db->select_sum($column);
    }
    $query $this->db->get();
    if ($total == 'true'){
    return $query->row();
    } else {
    return $query->result();    
    
}
    
  


This is the error that I am getting

Quote:Error Number: 1140

In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'project.analytics_page_views.id'; this is incompatible with sql_mode=only_full_group_by

SELECT *, SUM(`page_hits`) AS `page_hits` FROM `analytics_page_views` WHERE MONTH(date) = 2 AND YEAR(date) = 2017

Filename: C:/wamp/www/system/database/DB_driver.php

Line Number: 691


Can anyone help please with understanding this error?

Thanks,
Doomie


RE: In aggregated without GROUP BY error - JayAdra - 03-01-2017

I had the same issue, see the following answer for a well-put explanation:
http://stackoverflow.com/a/38551525


RE: In aggregated without GROUP BY error - doomie22 - 03-02-2017

I have been looking at this post but I just cannot understand what it really means and how I can fix it Sad