corr
Function
The corr function is used to return the correlation coefficient of two numeric columns.
Syntax
corr(col1, col2)
Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| col1 | Yes | DOUBLE, BIGINT, INT, SMALLINT, TINYINT, FLOAT, or DECIMAL | A column with numeric data type. Other types return NULL. |
| col2 | Yes | DOUBLE, BIGINT, INT, SMALLINT, TINYINT, FLOAT, or DECIMAL | A column with numeric data type. Other types return NULL. |
Return Values
Returns a value of type DOUBLE.
Examples
- Calculate the correlation coefficient between all items inventory and price. Example command:
select corr(items,price) from warehouse;
Result:
_c0 1.242355
- Used with GROUP BY to group all items by warehouse (warehouseId) and calculate the correlation coefficient between items inventory and price within the same group. Example command:
select warehouseId, corr(items,price) from warehouse group by warehouseId;
Result:
warehouseId _c1 city1 0.43124 city2 0.53344 city3 0.73425
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