Adds a COUNT aggregate to the SELECT section.

@param string|\Closure|Query|StatementInterface $column Column to count
@param string|null $alias Aggregate alias name
@return $this
@throws InvalidArgumentException
@throws InvalidReturnValueException
512880
public function addCount($column = '*', string $alias = null): self
    {
        return $this->addAggregate('COUNT', $column, $alias);
    }
616312
public function avg($column, $alias)
    {
        return $this->addSelectColumn(new Func\Avg(new Expr\Column($column)), $alias);
    }
748698
public function min(string $column, string $alias = null)
    {
        $this->columnRaw($this->dialect()->min($column, $alias));

        return $this;
    }
852900
public function format($column, int $format, string $alias = null): self
    {
        return $this->column((new Expression())->format($column, $format), $alias);
    }
1214927
public function select($column, string $alias = null): self
    {
        if (\is_string($column)) {
            if (\strpos($column, ',')) {
                $this->select = \array_merge($this->select, \array_filter(\explode(',', $column)));
            } else {
                $this->select[$column] = $alias;
            }
        } elseif (\is_array($column)) {
            foreach ($column as $col => $ali) {
                if (\is_numeric($col)) {
                    $this->select[$ali] = null;
                } else {
                    $this->select[$col] = $ali;
                }
            }
        }

        return $this;
    }
49393
public function stats($alias, $field = null, $script = null)
    {
        $aggregation = new StatsAggregation($alias, $field, $script);

        $this->append($aggregation);
    }
1274950
public function chunkById($count, callable $callback, $column = null, $alias = null)
    {
        $column = is_null($column) ? $this->getModel()->getKeyName() : $column;

        $alias = is_null($alias) ? $column : $alias;

        $lastId = 0;

        do {
            $clone = clone $this;

            // We'll execute the query for the given page and get the results. If there are
            // no results we can just break and return from here. When there are results
            // we will call the callback with the current chunk of these results here.
            $results = $clone->forPageAfterId($count, $lastId, $column)->get();

            $countResults = $results->count();

            if ($countResults === 0) {
                break;
            }

            // On each chunk result set, we will pass them to the callback and then let the
            // developer take care of everything within the callback, which allows us to
            // keep the memory low for spinning through large result sets for working.
            if ($callback($results) === false) {
                return false;
            }

            $lastId = $results->last()->{$alias};
        } while ($countResults === $count);

        return true;
    }
687307
public function count(string $column = '*'): int
    {
        $select = clone $this;

        //To be escaped in compiler
        $select->columns = ["COUNT({$column})"];
        $select->ordering = [];
        $select->grouping = [];

        $st = $select->run();
        try {
            return (int)$st->fetchColumn();
        } finally {
            $st->close();
        }
    }
718745
public function count($column = null){
		if($column === null){
			$this->performed || $this->run();
			return (int) $this->connection->getDriver()->getNumRows($this->resultSet);
		}
		return $this->aggregation("COUNT(:$column)");
	}
1288301
public function selectMax(string $column, string $alias = null)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->max($column, $alias);

        return $instance;
    }
1366071
public function len($column, $alias = null)
    {
        $this->queryBuilder->len($column, $alias);
        return $this;
    }
1133502
public function sum($column, $alias = null)
    {
        $this->queryBuilder->sum($column, $alias);
        return $this;
    }
1162803
public function lcase($column, string $alias = null): self
    {
        return $this->column((new Expression())->lcase($column), $alias);
    }
572
public function count($alias = null)
    {
        if ($this->controller && $this->controller->hasMethod('count')) {
            return $this->controller->count($this, $alias);
        }
        throw $this->exception('The controller doesn\'t support count', 'NotImplemented')
            ->addMoreInfo('controller', $this->controller ? $this->controller->short_name : 'none');
    }
986288
public function sum(string $column, string $alias = null)
    {
        $this->columnRaw($this->dialect()->sum($column, $alias));

        return $this;
    }
196446
public static function count(string $column, string $as = null, string $tableAlias = null): self
    {
        return new self(Aggregation\Type::COUNT, $column, $as, $tableAlias);
    }
1156762
public function count($column = '*')
    {
        if ($column != '*') {
            $column = '`' . $column . '`';
        }

        $sql = 'select count(' . $column . ') from `' . $this->table .'`';

        if ($this->where !== null) {
            $sql .= ' where ' . $this->where;

            $this->where = null;
        }

        $stmt = $this->connection->prepare($sql);

        $this->bind($stmt, $this->where_data_binding);

        $this->where_data_binding = [];

        $stmt->execute();

        $r = $stmt->fetchColumn();

        return (int) $r;
    }