covar_pop¶
This function is used to return the covariance between two columns of numerical values.
Syntax¶
covar_pop(col1, col2)
Parameters¶
Parameter | Mandatory | Description |
---|---|---|
col1 | Yes | Columns with a data type of numeric. If the values are of any other type, NULL is returned. |
col2 | Yes | Columns with a data type of numeric. If the values are of any other type, NULL is returned. |
Return Values¶
The return value is of the DOUBLE type.
Example Code¶
Calculates the covariance between the inventory (items) and the price of all offerings. An example command is as follows:
select covar_pop(items, price) from warehouse;
The command output is as follows:
_c0 1.242355
When used with group by, it groups all offerings by warehouse (warehourseId) and returns the covariance between the inventory (items) and the price of offerings within each group. An example command is as follows:
select warehourseId, covar_pop(items, price) from warehourse group by warehourseId;
The command output is as follows:
warehouseId _c1 city1 1.13124 city2 1.13344 city3 1.53425