This function is used to return the sample covariance between two columns of numerical values.
covar_samp(col1, col2)
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. |
The return value is of the DOUBLE type.
select covar_samp(items,price) from warehouse;
The command output is as follows:
_c0 1.242355
select warehourseId, covar_samp(items,price) from warehourse group by warehourseId;
The command output is as follows:
warehouseId _c1 city1 1.03124 city2 1.03344 city3 1.33425