COVAR_POP

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Computes the population covariance between two sets of values.

Syntax

covar_pop(<Y>, <X>)

Arguments

Required

  • <Y>: A double precision expression.
  • <X>: A double precision expression.

Returns

Returns a double precision value representing the population covariance. Returns NULL if the computation is meaningless.

Considerations

  • Returns NULL if there are no rows where both X and Y are non-null.
  • Population covariance uses N in the denominator.
  • Use COVAR_SAMP for sample covariance (uses N-1 in the denominator).

Examples

Calculate Population Covariance

Find the population covariance between two variables.

SELECT covar_pop(height, weight) AS covariance
FROM measurements;

Covariance by Group

Calculate covariance for each group.

SELECT region, covar_pop(sales, temperature) AS sales_temp_cov
FROM regional_data
GROUP BY region;

Related Documentation