ClickHouse/docs/en/sql-reference/aggregate-functions/reference/stddevsamp.md

1.3 KiB

slug sidebar_position
/en/sql-reference/aggregate-functions/reference/stddevsamp 31

stddevSamp

The result is equal to the square root of varSamp.

Alias: STDDEV_SAMP.

:::note This function uses a numerically unstable algorithm. If you need numerical stability in calculations, use the stddevSampStable function. It works slower but provides a lower computational error. :::

Syntax

stddevSamp(x)

Parameters

Returned value

Square root of sample variance of x. Float64.

Example

Query:

DROP TABLE IF EXISTS test_data;
CREATE TABLE test_data
(
    population UInt8,
)
ENGINE = Log;

INSERT INTO test_data VALUES (3),(3),(3),(4),(4),(5),(5),(7),(11),(15);

SELECT
    stddevSamp(population)
FROM test_data;

Result:

┌─stddevSamp(population)─┐
│                      4 │
└────────────────────────┘