MySQL STDDEV_SAMP() Function
The MySQL STDDEV_SAMP()
function calculates the sample standard deviation of all non-null input values and returns the result.
STDDEV_SAMP()
Syntax
Here is the syntax for MySQL STDDEV_SAMP()
function:
STDDEV_SAMP(expr)
We usually use the STDDEV_SAMP()
function like this:
SELECT STDDEV_SAMP(expr), ...
FROM table_name
[WHERE ...];
Or use the STDDEV_SAMP()
function with the GROUP BY
clause:
SELECT STDDEV_SAMP(expr), group_expr1, group_expr2, ...
FROM table_name
[WHERE ...]
GROUP BY group_expr1, group_expr2, ...;
Parameters
expr
-
Required. A column name or expression. It accepts a numeric or binary value.
Return value
The MySQL STDDEV_SAMP()
function returns the sample standard deviation of all non-null input values .
Note that the STDDEV_SAMP()
function only handles non-null values. That is, null values are ignored by the STDDEV_SAMP()
function.
If all input values are null, the function will return NULL
.
STDDEV_SAMP()
Examples
To demonstrate usages of the MySQL BIT_AND()
function, we simulate a temporary table using the following statement and UNION
and SELECT
:
SELECT 4 x
UNION
SELECT 5 x
UNION
SELECT 6 x;
+---+
| x |
+---+
| 4 |
| 5 |
| 6 |
+---+
3 rows in set (0.00 sec)
The following statement uses the STDDEV_SAMP()
function to calculate the sample standard deviation of all the values in the x
column:
SELECT STDDEV_SAMP(x)
FROM (
SELECT 4 x
UNION
SELECT 5 x
UNION
SELECT 6 x
) t;
+----------------+
| STDDEV_SAMP(x) |
+----------------+
| 1 |
+----------------+