src/ORM/Queries/SQLSelect.php
public function aggregate($column, $alias = null)
    {

        $clone = clone $this;

        // don't set an ORDER BY clause if no limit has been set. It doesn't make
        // sense to add an ORDER BY if there is no limit, and it will break
        // queries to databases like MSSQL if you do so. Note that the reason
        // this came up is because DataQuery::initialiseQuery() introduces
        // a default sort.
        if ($this->limit) {
            $clone->setLimit($this->limit);
            $clone->setOrderBy($this->orderby);
        } else {
            $clone->setOrderBy(array());
        }

        $clone->setGroupBy($this->groupby);
        if ($alias) {
            $clone->setSelect(array());
            $clone->selectField($column, $alias);
        } else {
            $clone->setSelect($column);
        }

        return $clone;
    }
public function aggregate($column, $alias = null)
    {

        $clone = clone $this;

        // don't set an ORDER BY clause if no limit has been set. It doesn't make
        // sense to add an ORDER BY if there is no limit, and it will break
        // queries to databases like MSSQL if you do so. Note that the reason
        // this came up is because DataQuery::initialiseQuery() introduces
        // a default sort.
        if ($this->limit) {
            $clone->setLimit($this->limit);
            $clone->setOrderBy($this->orderby);
        } else {
            $clone->setOrderBy(array());
        }

        $clone->setGroupBy($this->groupby);
        if ($alias) {
            $clone->setSelect(array());
            $clone->selectField($column, $alias);
        } else {
            $clone->setSelect($column);
        }

        return $clone;
    }
public function aggregate ( $ column , $ alias = null ) { $ clone = clone $ this ; // don't set an ORDER BY clause if no limit has been set. It doesn't make // sense to add an ORDER BY if there is no limit, and it will break // queries to databases like MSSQL if you do so. Note that the reason // this came up is because DataQuery::initialiseQuery() introduces // a default sort. if ( $ this -> limit ) { $ clone -> setLimit ( $ this -> limit ) ; $ clone -> setOrderBy ( $ this -> orderby ) ; } else { $ clone -> setOrderBy ( array ( ) ) ; } $ clone -> setGroupBy ( $ this -> groupby ) ; if ( $ alias ) { $ clone -> setSelect ( array ( ) ) ; $ clone -> selectField ( $ column , $ alias ) ; } else { $ clone -> setSelect ( $ column ) ; } return $ clone ; }
Return a new SQLSelect that calls the given aggregate functions on this data.

@param string $column An aggregate expression, such as 'MAX("Balance")', or a set of them
(as an escaped SQL statement)
@param string $alias An optional alias for the aggregate column.
@return SQLSelect A clone of this object with the given aggregate function
Return a new SQLSelect that calls the given aggregate functions on this data .