Definition:
The Oracle VAR_POP function returns the population variance of a set of numbers after discarding the nulls in this set. The VAR_POP function can be used as both an aggregate and analytic function.
The VAR_POP function takes as an argument any numeric datatype (or any non-numeric datatype that can be implicitly converted to a numeric datatype). The function returns the same datatype as the numeric datatype of the argument.
Example Syntax:
VAR_POP(<value>) OVER (<analytic_clause>);
value is a numeric expression or any non-numeric expression that can be implicitly converted to a numeric datatype.
Example Usage:
This example returns the variance of sales by month:
SELECT t.calendar_month_desc, VAR_POP(SUM(s.amount_sold))
OVER (ORDER BY t.calendar_month_desc) "Var_Pop",
VAR_SAMP(SUM(s.amount_sold))
OVER (ORDER BY t.calendar_month_desc) "Var_Samp"
FROM sales s, times t
WHERE s.time_id = t.time_id AND t.calendar_year = 2010
GROUP BY t.calendar_month_desc;
Related Links:
Related Code Snippets:
- COVAR_POP - COVAR_POP returns the population covariance of a set of number pairs. Both expr1 and e...
