STDDEV_POP [analytic]

计算统计总体标准差,并返回 窗口内总体方差的平方根。STDDEV_POP() 返回值与 VAR_POP() 函数的平方根相同:

STDDEV_POP( expression ) = SQRT(VAR_POP( expression ))

VAR_POP 返回 Null 时,STDDEV_POP 返回 Null。

行为类型

不可变

语法

STDDEV_POP ( expression ) OVER (
    [ window-partition-clause ]
    [ window-order-clause ]
    [ window-frame-clause ] )

参数

表达式
任何 NUMERIC 数据类型或可隐式转换为数字数据类型的任何非数字数据类型。函数返回的数据类型与参数的数字数据类型相同。
OVER()
请参阅分析函数

示例

以下示例返回雇员维度表中副经理的薪资总体标准差:

=> SELECT employee_last_name, annual_salary,
       STDDEV_POP(annual_salary) OVER (ORDER BY hire_date) as "stddev_pop"
   FROM employee_dimension WHERE job_title =  'Assistant Director';
 employee_last_name | annual_salary |    stddev_pop
--------------------+---------------+------------------
 Goldberg           |         61859 |                0
 Miller             |         79582 |           8861.5
 Goldberg           |         74236 | 7422.74712548456
 Campbell           |         66426 | 6850.22125098891
 Moore              |         66630 | 6322.08223926257
 Nguyen             |         53530 | 8356.55480080699
 Harris             |         74115 | 8122.72288970008
 Lang               |         59981 | 8053.54776538731
 Farmer             |         60597 | 7858.70140687825
 Nguyen             |         78941 | 8360.63150784682

另请参阅