title: Get the result of SUM and group field from Active record in Codeigniter
body: <p>I need to build this query in Codeigniter but I don't know how to get the result of the SUM:</p>
  
  <pre><code>SELECT 
      description, SUM(amount)
  FROM
      PAYMENT
  WHERE
      (date_payment between '2014-02-01 00:00:00' AND '2014-02-28 23:59:59')
  GROUP BY description;
  </code></pre>
  
  <p>I'm trying to get the result with this:</p>
  
  <pre><code>$qwer = $this-&gt;db-&gt;query("
      SELECT description, SUM(amount)
      FROM PAYMENT
      WHERE (date_payment between '$min_date' AND '$max_date')
      GROUP BY description;");
  
  $i = 0;
  foreach ($qwer-&gt;result() as $payment) {
      $det_payment[$i] = array(
          'description'=&gt;$payment-&gt;description,
          'amount'=&gt;$payment-&gt;amount
      );
      $i++;
  }
  </code></pre>
  
  <p>Of course "$payment->amount" is wrong, but if I use an alias for the SUM, the model doesn't work.</p>
  
  <p>EDIT: Right now I can choose between the description or the sum, but I can't use both select and select_sum</p>
  
  <pre><code>$this-&gt;db-&gt;select('description');
  //$this-&gt;db-&gt;select_sum('amount', 'amount');
  $this-&gt;db-&gt;where('date_payment &gt;=', $min_fecha);
  $this-&gt;db-&gt;where('date_payment &lt;=', $max_fecha);
  $this-&gt;db-&gt;group_by("description");
  $qwer = $this-&gt;db-&gt;get('PAYMENT');
  </code></pre>