Adds a SUM aggregate to the SELECT section.

@param string|\Closure|Query|StatementInterface $column Column to get sum
@param string|null $alias Aggregate alias name
@return $this
@throws InvalidArgumentException
@throws InvalidReturnValueException
498745
public function addSum($column, string $alias = null): self
    {
        return $this->addAggregate('SUM', $column, $alias);
    }
1366071
public function len($column, $alias = null)
    {
        $this->queryBuilder->len($column, $alias);
        return $this;
    }
391085
public function selectSelect(SelectQuery $column, ?string $alias = null)
    {
        $instance = $this->selectQueryInstance();

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

        return $instance;
    }
1088233
public function avg($column, bool $distinct = false): self
    {
        return $this->addFunction('aggregateFunction', 'AVG', $column, ['distinct' => $distinct]);
    }
1169109
public function add(ClassInterface $import, $alias = NULL) {
    if (empty($alias)) {
      $alias = $import->getName();
    }

    if (empty($alias)) {
      throw new InvalidArgumentException('GClass: '.$import.' must have a valid FQN: '.$import->getFQN());
    }
    
    if (array_key_exists($lowerAlias = mb_strtolower($alias), $this->aliases)) {
      $usedBy = $this->classes[ $this->aliases[$lowerAlias] ];

      if (!$import->equals($usedBy)) {
        throw new LogicException('Alias: '.$alias.' is already used by Class '.$usedBy);
      }
    }
    
    $this->classes[$alias] = $import;
    $this->aliases[$lowerAlias] = $alias;
    return $this;
  }
918905
public function addAlias($alias = null)
    {
        return (new AuthorizationBuilder(TransactionType::ALIAS, $this))
            ->withAlias(AliasAction::ADD, $alias);
    }
1299821
public function column($name, string $alias = null): self
    {
        $this->sql->addColumn($name, $alias);
        return $this;
    }
57527
public function addFieldCount($field, $alias = null)
    {
        $this->addField(new Func('count', $field), $alias); return $this;
    }
150139
public function add(Command $command, string $alias = '', bool $default = false): self
    {
        $name = $command->name();

        if ($this->commands[$name] ?? $this->aliases[$name] ?? $this->commands[$alias] ?? $this->aliases[$alias] ?? null) {
            throw new InvalidArgumentException(\sprintf('Command "%s" already added', $name));
        }

        if ($alias) {
            $command->alias($alias);
            $this->aliases[$alias] = $name;
        }

        if ($default) {
            $this->default = $name;
        }

        $this->commands[$name] = $command->version($this->version)->onExit($this->onExit)->bind($this);

        return $this;
    }
912081
public function addAvg($column, string $alias = null): self
    {
        return $this->addAggregate('AVG', $column, $alias);
    }
399265
public function addColumn(Column $column)
    {
        $this->columns[] = $column;

        if ($column instanceof ColumnInterface) {
            $column->initialize($this);
        }

        return $this;
    }
655314
public function round($column, int $decimals = 0, string $alias = null): self
    {
        return $this->column((new Expression())->format($column, $decimals), $alias);
    }
868616
public function max($column, $alias)
    {
        return $this->addSelectColumn(new Func\Max(new Expr\Column($column)), $alias);
    }
1165167
public function selectColumn(string $column, ?string $alias = null)
    {
        $instance = $this->selectQueryInstance();

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

        return $instance;
    }
1085532
public function count($column, $alias)
    {
        return $this->addSelectColumn(new Func\Count(new Expr\Column($column)), $alias);
    }
1101789
public function selectSum(string $column, string $alias = null)
    {
        $instance = $this->selectQueryInstance();

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

        return $instance;
    }
619095
public function groupBy($column)
    {
        if (is_null($column)) {
            throw new \InvalidArgumentException('Cannot pass null argument to '.__METHOD__);
        }

        if (is_array($column)) {
            $this->groupBy = $this->extractArrayAttributes($column);

            return $this;
        }

        $this->groupBy = $this->quoteIdentifier($column);

        return $this;
    }