CORRELATION
computes the correlation coefficient between two numeric attributes for all rows within a group.
CORRELATION
function is:
CORRELATION(<arg1>, <arg2>)where each argument is an arbitrary expression or a single-assign numeric (integer or double) attribute. Integer inputs are first promoted to doubles. Note that
CORRELATION
is symmetric (that is, the same result is returned regardless of which attribute is specified first).CORRELATION
ignores rows in which either argument is NULL and computes the correlation coefficient of the remaining rows. If all rows in the group are NULL, then CORRELATION
returns NULL.
The resulting Pearson product-moment correlation coefficient will be a value between +1 and −1 inclusive, where 1 is total positive correlation, 0 is no correlation, and −1 is total negative correlation. Note that there are cases where the output will be NaN (a common case is when there is only a single data point).
CORRELATION example
RETURN results AS SELECT CORRELATION(WineRating, Price) AS corr FROM WineState GROUP
The result might be a value of 0.886357407416268.