Retrieve the average of the values of a given column.

@param string $column

@return mixed
331691
public function avg($column)
    {
        $this->compileWheres();
        $result = $this->query->avg($column)
            ->rDefault(null)->run();

        return $result;
    }
195017
public function min(string $column = null)
    {
        if ($this->isNotEmpty()) {
            return min($this->toArray());
        }

        return false;
    }
947840
public function getColumn(string $column)
    {
        return isset($this->columnData[$column]) ? $this->columnData[$column] : null;
    }
859676
public function get($columns = ['*']) {
        if (count($columns) === 1 && isset($columns[0]) && $columns[0] === '*' && !empty($this->query->selects)) {
            return $this->query->all();
        }
        return $this->query->select($columns)->all();
    }
748395
public function column($column = '*')
    {
        if ('*' == $column) {
            $this->columns = ['*'];
        } else {
            $columns = $this->prepareNames(func_get_args());
            $this->columns = array_merge(
                empty($this->columns) || ['*'] == $this->columns ? [] : $this->columns,
                array_values(array_diff($columns, ['*']))
            );
        }
        return $this;
    }
1278597
public function calc($column)
    {
        $builder = clone $this;
        $builder->columns($column);

        $query = $builder->getQuery();
        $resultset = $query->execute();

        return $resultset->getFirst();
    }
274906
public function value( $column )
	{
		$result = $this->first( [$column] );

		return $result ? $result->{$column} : null;
	}
959505
public function avg($column = null)
    {
        $this->prepare();

        $count = $this->count();
        $total = $this->sum($column);

        return ($total/$count);
    }
1104309
public function values($column) {
		$res = [];
		while($row = $this->next())
			$res[] = $row[$column];
		return $res;
	}
645856
public function getColumnName( $column )
    {
        if ( $this->getColumnsUseTranslation() )
        {
            $column = $this->view->translate(
                $this->getColumnId( $column ),
                $this->getColumnTranslateTextDomain()
            );
        }

        return $column;
    }
1090879
public function max(string $column): int
    {
        $max = $this->queryRelate->getQuery()->max($column);

        $this->resetQueryRelate();

        return $max;
    }
1157234
public function getDataFullRead(string $column = null)
    {
        if (!empty($column))
            return (is_int($column) && isset($this->dicionario[$column]) ? $this->dicionario[$column]->getValue() : (!empty($value = $this->dicionario[$this->searchValue($column)]) ? $value->getValue() : null));

        $data = null;
        foreach ($this->dicionario as $meta) {
            if ($meta->getFormat() === "source" && preg_match('/"type": "image\//i', $meta->getValue())) {
                $data[$meta->getColumn()] = Helper::convertImageJson($meta->getValue());
            } elseif ($meta->getFormat() === "source") {
                $data[$meta->getColumn()] = json_decode($meta->getValue(), true)[0];
            } elseif (in_array($meta->getKey(), ["list", "selecao", "extend", "extend_add", "checkbox_rel"])) {
                $data[$meta->getColumn()] = Entity::read($meta->getRelation(), $meta->getValue());
            } elseif (in_array($meta->getFormat(), ["list_mult", "selecao_mult", "extend_mult", "checkbox_mult"])) {
                if (!empty($meta->getValue())) {
                    $lista = [];
                    foreach (json_decode($meta->getValue(), true) as $id) {
                        $lista[] = Entity::read($meta->getRelation(), $id);
                    }
                    $data[$meta->getColumn()] = $lista;
                }
            } elseif ($meta->getType() === "json") {
                $data[$meta->getColumn()] = json_decode($meta->getValue(), true);
            } else {
                $data[$meta->getColumn()] = $meta->getValue();
            }
        }

        return $data;
    }
542859
protected function getDecimal(array $column)
    {
        $digitsPerInteger = 9;
        $compressedBytes = [0, 1, 1, 2, 2, 3, 3, 4, 4, 4];
        $integral = $column['precision'] - $column['decimals'];
        $unCompIntegral = (int)($integral / $digitsPerInteger);
        $unCompFractional = (int)($column['decimals'] / $digitsPerInteger);
        $compIntegral = $integral - ($unCompIntegral * $digitsPerInteger);
        $compFractional = $column['decimals'] - ($unCompFractional * $digitsPerInteger);

        $value = $this->binaryDataReader->readUInt8();
        if (0 !== ($value & 0x80)) {
            $mask = 0;
            $res = '';
        } else {
            $mask = -1;
            $res = '-';
        }
        $this->binaryDataReader->unread(pack('C', $value ^ 0x80));

        $size = $compressedBytes[$compIntegral];
        if ($size > 0) {
            $value = $this->binaryDataReader->readIntBeBySize($size) ^ $mask;
            $res .= $value;
        }

        for ($i = 0; $i < $unCompIntegral; ++$i) {
            $value = $this->binaryDataReader->readInt32Be() ^ $mask;
            $res .= sprintf('%09d', $value);
        }

        $res .= '.';

        for ($i = 0; $i < $unCompFractional; ++$i) {
            $value = $this->binaryDataReader->readInt32Be() ^ $mask;
            $res .= sprintf('%09d', $value);
        }

        $size = $compressedBytes[$compFractional];
        if ($size > 0) {
            $value = $this->binaryDataReader->readIntBeBySize($size) ^ $mask;
            $res .= sprintf('%0' . $compFractional . 'd', $value);
        }

        return bcmul($res, 1, $column['precision']);
    }
439164
public function getSortColumn($column)
    {
        $val = null;

        if ($this->isSorted($column)) {
            $def = $this->sortColumns[$this->mappingSortColumns[$column]];

            if (isset($def['sort'])) {
                $val = $def['sort'];
            }
        }

        return $val;
    }
963949
public function getColumnDetail($column)
    {
        $columns = $this->getColumnDetails();

        return isset($columns[$column]) ? $columns[$column] : null;
    }
941027
public function fetchField($column)
    {
        if ($this->rowCount == 0) {
            throw new Exception('Empty result set');
        }
        $row = $this->current();
        if (!isset($this->columnOids[$column])) {
            throw new Exception("Field '$column' not found");
        }

        return $row[$column];
    }
43887
public function column($column = null)
	{
		if($column !== null)
		{
			$this->select([$column]);
		}

		$query = $this->limit(1)->compiler->select();

		return $this->connection->column($query['sql'], $query['params']);
	}