STDDEV_SAMP
Aggregate function.
The STDDEV_SAMP() function returns the sample standard deviation(the square root of VAR_SAMP()) of an expression.
Caution: NULL values are not counted.
Analyze Syntax
func.stddev_samp(<expr>)
Analyze Examples
func.stddev_samp(table.height).alias('height_stddev_samp')
| height_stddev_samp |
|--------------------|
| 0.240 |
SQL Syntax
STDDEV_SAMP(<expr>)
Arguments
Arguments | Description |
---|---|
<expr> | Any numerical expression |
Return Type
double
SQL Examples
Create a Table and Insert Sample Data
CREATE TABLE height_data (
id INT,
person_id INT,
height FLOAT
);
INSERT INTO height_data (id, person_id, height)
VALUES (1, 1, 5.8),
(2, 2, 6.1),
(3, 3, 5.9),
(4, 4, 5.7),
(5, 5, 6.3);
Query Demo: Calculate Sample Standard Deviation of Heights
SELECT STDDEV_SAMP(height) AS height_stddev_samp
FROM height_data;
Result
| height_stddev_samp |
|--------------------|
| 0.240 |
Last modified June 11, 2024 at 9:00 PM EST: clean up cautions and notes (d4a1b9a)