# stddev_samp

Calculates the sample standard deviation.

The result is the square root of the sample variance, [`var_samp`](https://coordinatordb.com/docs/reference/functions/aggregate-functions/var-samp). It has the same units as the observations.

**Syntax**

```text
stddev_samp(x)
```

**Arguments**

* `x` — A numeric column or expression. `NULL` values are skipped.

**Calculation**

```text
sqrt(sum((x - mean) * (x - mean)) / (n - 1))
```

`mean` is the arithmetic mean of the non-`NULL` values, and `n` is their count. The sample calculation uses `n - 1` because the observations estimate a larger population.

**Returned value**

An approximate `REAL` value. Fewer than two non-`NULL` inputs returns `NULL`. Nonfinite inputs return `NULL`; finite arithmetic overflow raises `NUMERIC_OVERFLOW`.

**Examples**

**Measuring the spread of readings**

```sql
CREATE TABLE readings (value INTEGER);
INSERT INTO readings VALUES (1), (3), (5), (7), (9), (NULL);
```

```sql
SELECT round(stddev_samp(value), 6) AS result
FROM readings
FORMAT csv;
```

```text
3.162278
```

**A single observation**

```sql
CREATE TABLE single_reading (value INTEGER);
INSERT INTO single_reading VALUES (7), (NULL);
```

```sql
SELECT stddev_samp(value)
FROM single_reading
FORMAT csv;
```

```text
\N
```
