STDDEV_POP() OVER ...
All functions > WINDOW FUNCTION > STDDEV_POP() OVER ...
Returns the population standard deviation over the window frame.
Syntax
STDDEV_POP(expr) [FILTER (WHERE condition) | WITHIN (WHERE condition)] OVER ([PARTITION BY expr [, ...]] [ORDER BY sort_item [, ...]] [ROWS|RANGE|GROUPS frame])
Notes
- Computes population standard deviation (divides by N) over a window of rows
- NULL values are ignored in the calculation
See also
Examples
FeatureQL
SELECT
-- Population std dev over the frame (id is only the sort key)
f1 := ZIP(ARRAY(1, 2, 3, 4) AS id, ARRAY(30, 10, 20, 5) AS v).TRANSFORM(
SELECT STDDEV_POP(CAST(v AS DOUBLE)) OVER (ORDER BY id ASC).ROUND(2)
).UNWRAP(),
-- Population std dev counting only rows where v > 15 (10 and 5 excluded from the frame)
f2 := ZIP(ARRAY(1, 2, 3, 4) AS id, ARRAY(30, 10, 20, 5) AS v).TRANSFORM(
SELECT STDDEV_POP(CAST(v AS DOUBLE)) FILTER (WHERE v > 15) OVER (
ORDER BY id ASC
).ROUND(
2
)
).UNWRAP()
;Result
| f1 ARRAY | f2 ARRAY |
|---|---|
| [0.00, 10.00, 8.16, 9.60] | [0.00, 0.00, 5.00, 5.00] |