# variance\_samp

[Read this page in HTML](https://www.scopedb.io/docs/reference/functions/aggregate/variance_samp)

Returns the sample variance of non-NULL values.

## Syntax

```scopeql
variance_samp(<expr>)
```

## Arguments

| Argument | Type                      | Description  |
| -------- | ------------------------- | ------------ |
| `<expr>` | `int`, `uint`, or `float` | Input value. |

## Returns

Returns `float`. Ignores NULL values. Returns NULL when fewer than two non-NULL values are available.

## Examples

Estimate how much request latency varies across channels from a sample of requests:

```scopeql
VALUES
    ('web', 100.0), ('web', 120.0), ('web', 140.0),
    ('mobile', 60.0), ('mobile', 120.0), ('mobile', 180.0)
SELECT $0 AS channel, $1 AS latency_ms
GROUP BY channel
AGGREGATE avg(latency_ms) AS avg_ms, variance_samp(latency_ms) AS variance_ms2
ORDER BY channel
```

```text
+---------+--------+--------------+
| channel | avg_ms | variance_ms2 |
+---------+--------+--------------+
| mobile  | 120.0  | 3600.0       |
| web     | 120.0  | 400.0        |
+---------+--------+--------------+
```

Both channels average 120 ms, but mobile durations vary more. The sample variance is measured in ms².
