COVAR_SAMP
COVAR_SAMP(expression1, expression2)
Section titled “COVAR_SAMP(expression1, expression2)”- 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.
Example
Section titled “Example”SELECT COVAR_SAMP(salary, commission_pct)AS Sample_CovarianceFROM employees;Output
Section titled “Output”SAMPLE_COVARIANCE-----------------12245.8387552346Explanation
Section titled “Explanation”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.
COVAR_SAMP(Y, X)
Section titled “COVAR_SAMP(Y, X)”- y: This is the first expression that is a number, and it represents the dependent variable in the covariance calculation.
- x: This is the second expression that is a number, and it represents the independent variable in the covariance calculation.
Example
Section titled “Example”SELECT COVAR_SAMP(column1, column2)FROM table_name;Output
Section titled “Output” covar_samp------------------------------ 13487.1442948399004Explanation
Section titled “Explanation”In the given example, the COVAR_SAMP() function returns the sample covariance of a set of number pairs. Covariance is a measure that illustrates how two variables are related to each other. If the above variance was derived from column1 and column2 of a table, it indicates that these two columns have a covariance of approximately 13487.14. This can suggest a positive linear relation, as covariance > 0 typically signifies that larger values of one variable correspond with larger values of the other.