VAR_POP
This function returns the overall variance of the grouped series.
Example:
SELECT empno, sal, VAR_pop(sal) OVER (ORDER BY hiredate) as "var_pop"
FROM emp ORDER BY ename, sal, "var_pop" ;
EMPNO | SAL | var_pop
------------+----------+----------------------
7876 | 8100 | 2799183.333333333333
7499 | 7600 | 1386666.666666666667
7698 | 11850 | 4748003.472222222222
7782 | 7450 | 4070841.836734693878
7902 | 8000 | 3328381.076388888889
7900 | 5950 | 3328381.076388888889
7566 | 7975 | 1251400
7839 | 10000 | 3729306.25
7654 | 6250 | 3401111.111111111111
7934 | 6300 | 3166597.633136094675
7788 | 8000 | 2967286.352040816327
7469 | 4800 | 1000000
7369 | 6800 | 1000000
7844 | 6500 | 3678505.859375
7521 | 6250 | 1044218.75
(15 rows)
VAR_SAMP
This function returns the sample variance of the grouped series.
For example:
SELECT empno, sal, VAR_samp(sal) OVER (ORDER BY hiredate) as "var_samp"
FROM emp ORDER BY ename, sal, "var_samp" ;
EMPNO | SAL | var_samp
-------+-------+-----------------------
7876 | 8100 | 2999125
7499 | 7600 | 2080000
7698 | 11850 | 5697604.166666666667
7782 | 7450 | 4749315.47619047619
7902 | 8000 | 3630961.174242424242
7900 | 5950 | 3630961.174242424242
7566 | 7975 | 1564250
7839 | 10000 | 4143673.611111111111
7654 | 6250 | 3826250
7934 | 6300 | 3430480.769230769231
7788 | 8000 | 3195539.148351648352
7469 | 4800 | 2000000
7369 | 6800 | 2000000
7844 | 6500 | 4204006.696428571429
7521 | 6250 | 1392291.666666666667
(15 rows)
Top comments (0)