covar_samp
Function
The covar_samp function is used to return the sample covariance of two numeric columns.
Syntax
covar_samp(col1, col2)
Parameters
| Parameter | Mandatory | Description |
|---|---|---|
| col1 | Yes | A column with numeric data type. Other types return NULL. |
| col2 | Yes | A column with numeric data type. Other types return NULL. |
Return Values
Returns a value of type DOUBLE.
Examples
- Calculate the sample covariance between all items inventory and price. Example command:
select covar_samp(items,price) from warehouse;
Result:
_c0 1.242355
- Used with GROUP BY to group all items by warehouse (warehouseId) and calculate the sample covariance between items inventory and price within the same group. Example command:
select warehouseId, covar_samp(items,price) from warehouse group by warehouseId;
Result:
warehouseId _c1 city1 1.03124 city2 1.03344 city3 1.33425
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot