# `Lotus.Result.Statistics`
[🔗](https://github.com/typhoonworks/lotus/blob/v0.16.6/lib/lotus/result/statistics.ex#L1)

Computes column-level statistics from in-memory query results.

Operates entirely on the data already present in a `%Lotus.Result{}` struct,
requiring no additional database queries. Statistics are computed per-column
and vary based on the detected column type (numeric, string, or temporal).

# `column_stats`

```elixir
@type column_stats() :: map()
```

# `column_type`

```elixir
@type column_type() :: :numeric | :string | :temporal | :unknown
```

# `compute`

```elixir
@spec compute(Lotus.Result.t(), String.t()) ::
  {:ok, column_stats()} | {:error, String.t()}
```

Computes statistics for a single column in the result set.

Returns a map with `:type` and type-specific statistics keys.
Returns `{:error, reason}` if the column is not found.

# `compute_all`

```elixir
@spec compute_all(Lotus.Result.t()) :: %{required(String.t()) =&gt; column_stats()}
```

Computes statistics for all columns in the result set.

Returns a map of `%{column_name => stats_map}`.

# `detect_column_type`

```elixir
@spec detect_column_type(Lotus.Result.t(), String.t()) ::
  column_type() | {:error, String.t()}
```

Detects the column type from its values.

Inspects non-nil values and returns `:numeric`, `:string`, `:temporal`, or `:unknown`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
