Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
Computes the sample standard deviation of input values.
Syntax
stddev(<expression>)
Arguments
Required
<expression>: An expression of any numerical type.
Returns
NUMERIC(38,6)for integer-type or numeric arguments.double precisionfor floating-point arguments.
Returns NULL if the computation is meaningless.
Considerations
- Uses N-1 in the denominator (Bessel's correction).
- Use
STDDEV_POPfor population standard deviation. - Cast the input to
double precisionto get adouble precisionresult.
Examples
Calculate Standard Deviation
Find the standard deviation of prices.
SELECT stddev(price) AS price_stddev
FROM products;
Standard Deviation by Group
Calculate standard deviation for each category.
SELECT category, stddev(price) AS price_stddev
FROM products
GROUP BY category;
Force Double Precision Output
Cast to get a specific output type.
SELECT stddev(CAST(quantity AS double precision)) AS qty_stddev
FROM orders;