title: Codeigniter: How to include SUM() and COUNT() in JOIN query?
body: <p>I have this method in my Model</p>
  
  <pre><code>function get_users_details(){
          $this-&gt;db-&gt;select("a.*,sum('b.downloads') as downloads,COUNT('b.user_email') as uploads");
          $this-&gt;db-&gt;from('user a');
          $this-&gt;db-&gt;join('files b', 'a.email = b.user_email','inner');
  
          $query = $this-&gt;db-&gt;get();
          if($query-&gt;num_rows() &gt; 0)
          {
              foreach ($query-&gt;result_array() as $row){
                  $data[] = $row;
              }
          $query-&gt;free_result();
          return $data;
          }
          else{
              return false;
          }
      }
  </code></pre>
  
  <p>It only returns values from a single row while actually it supposed to return values from multiple rows.</p>