code: public function aggregate($function, $columns = array('*')) {
      // Postgres doesn't like ORDER BY when there's no GROUP BY clause
      if ( !isset($this->groups) )
        $this->reOrderBy(null);
  
      return parent::aggregate($function, $columns);
    }
docs: Execute an aggregate function on the database.
  
  @param  string  $function
  @param  array   $columns
  @return mixed