Skip to content

COVAR_SAMP

  • expression1: The first set of numbers in a pair for which you want to calculate the covariance. It should be a number, and all non-null items in the list are included in the calculation.
  • expression2: The corresponding second set of numbers in a pair for which you want to calculate the covariance. Like the first expression, it should be a number and all non-null items in the list are included in the calculation.
SELECT COVAR_SAMP(salary, commission_pct)
AS Sample_Covariance
FROM employees;
SAMPLE_COVARIANCE
-----------------
12245.8387552346

This function computes the sample covariance of a pair of number sets. Here, salary and commission_pct from the employees table are used. The result, 12245.8387552346, represents their sample covariance.