title: Group By with codeigniter doesn't work with empty records
body: <p>I'm having a problem with the Codeigniter.</p>
  
  <p>I have three tables, the first "videos" contains all the videos, the second "video_author" contains all authors and the third "videos_views" contains the views of the videos.</p>
  
  <p>I need to select all the videos of the first table, do a join on second table and do a join on the third table, until there everything works normal with the code below:</p>
  
  <pre><code>    $total_records = $this-&gt;db-&gt;count_all_results('videos');
      $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('videos');
      $this-&gt;db-&gt;where('videos_publication', '1');
      $this-&gt;db-&gt;join('video_author','video_author.video_author_id=videos.videos_author_id','left');
      $this-&gt;db-&gt;where('videos_id &gt;=', $total_records - 20);
      $this-&gt;db-&gt;join('videos_views','videos_views.videos_views_id=videos.videos_id','left');
      $this-&gt;db-&gt;order_by("videos_views_total","desc");        
      $this-&gt;db-&gt;limit(20);
      $query_result = $this-&gt;db-&gt;get();
      $result = $query_result-&gt;result();
      return $result;
  </code></pre>
  
  <p>But I need to do a SELECT SUM to count the views of the videos tables and after a groupby to group the data according to the month, the biggest problem is that if you do not have a record on the views table, none value returns.</p>
  
  <p>Code I'm using:</p>
  
  <p>$total_records = $this->db->count_all_results('videos');</p>
  
  <pre><code>    $this-&gt;db-&gt;select('*');
      $this-&gt;db-&gt;from('videos');
      $this-&gt;db-&gt;where('videos_publication', '1');
      $this-&gt;db-&gt;join('video_author','video_author.video_author_id=videos.videos_author_id','left');
      $this-&gt;db-&gt;where('videos_id &gt;=', $total_records - 20);
      $this-&gt;db-&gt;join('videos_views','videos_views.videos_views_id=videos.videos_id','left');
      $this-&gt;db-&gt;select('SUM(videos_views_total)');
      $this-&gt;db-&gt;group_by('MONTH(videos_views_date)');
      $this-&gt;db-&gt;group_by('videos_views_id');
      $this-&gt;db-&gt;order_by("videos_views_total","desc");        
      $this-&gt;db-&gt;limit(20);
      $query_result = $this-&gt;db-&gt;get();
      $result = $query_result-&gt;result();
      return $result;
  </code></pre>
  
  <p>if the table "videos_views" has the records, it returns perfectly.</p>
  
  <p>Every help is welcome</p>