STDDEV_SAMP function

STDDEV_SAMP is an aggregate function that evaluates the sample deviation of an expression over a set of rows.

See Aggregates (set functions) for more information about these functions.

STDDEV_SAMP is allowed only on expressions that evaluate to numeric data types.

Syntax

STDDEV_SAMP ( expression )

The expression can contain multiple column references or expressions, but it cannot contain another aggregate or subquery. It must evaluate to a built-in numeric data type. If an expression evaluates to NULL, the aggregate skips that value.

The resulting data type is DOUBLE (it might overflow).

Formula

Sample deviation is calculated as follows:


sqrt( var_samp() )

Example

-- find the sample deviation in flight time per aircraft
SELECT AIRCRAFT, STDDEV_SAMP( flying_time )
FROM flights GROUP BY aircraft;