STDDEV/STDDEV_SAMP

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 precision for floating-point arguments.

Returns NULL if the computation is meaningless.

Considerations

  • Uses N-1 in the denominator (Bessel's correction).
  • Use STDDEV_POP for population standard deviation.
  • Cast the input to double precision to get a double precision result.

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;

Related Documentation