Name
STDDEV_SAMP
Synopsis
Use STDDEV_SAMP to find the sample standard deviation within a group of numeric values.
SQL2003 Syntax
STDDEV_SAMP( numeric_expression
)
Oracle
Oracle supports the standard syntax. Oracle also provides the STDDEV function, which operates similar to STDDEV_SAMP except that it returns zero as not NULL when there is only one value in the set.
Oracle also supports analytic syntax:
STDDEV_SAMP (numeric_expression
) OVER (window_clause
)
For an explanation of the window_clause
,
see the section later in this chapter titled Section 4.3.
DB2
This platform does not provide a function to compute sample standard deviation.
MySQL
MySQL does not provide a function to compute sample standard deviation. MySQL does provide a function named STDDEV, but it returns the population standard deviation.
PostgreSQL
Use STDDEV.
SQL Server
Use STDEV (with only one D!).
Example
The following example computes the sample standard deviation for the values 1, 2, and 3:
SELECT * FROM test;
X ---------- 1 2 3SELECT STDDEV_SAMP(x) FROM test;
STDDEV_SAMP(X) -------------- 1
Get SQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.