15.00 - COVAR_POP - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)
Last Update
2018-09-24

COVAR_POP

Purpose

Returns the population covariance of its arguments for all non-null data point pairs.

Syntax

where:

 Syntax element … Specifies … value_expression_2 a numeric expression to be paired with a second numeric expression to determine their covariance. The expressions cannot contain any ordered analytical or aggregate functions. value_expression_1

ANSI Compliance

This is ANSI SQL:2011 compliant.

Definition

Covariance measures whether or not two random variables vary in the same way. It is the average of the products of deviations for each non-null data point pair.

Note that high covariance does not imply a causal relationship between the variables.

Combination With Other Functions

COVAR_POP can be combined with ordered analytical functions in a SELECT list, QUALIFY clause, or ORDER BY clause. For more information on ordered analytical functions, see Chapter 22: “Ordered Analytical / Window Aggregate Functions.”

COVAR_POP cannot be combined with aggregate functions within the same SELECT list, QUALIFY clause, or ORDER BY clause.

Computation

The equation for computing COVAR_POP is defined as follows:

where:

 This variable … Represents … x value_expression_2 y value_expression_1

When there are no non-null data point pairs in the data used for the computation, then COVAR_POP returns NULL.

Division by zero results in NULL rather than an error.

Result Type and Attributes

The data type, format, and title for COVAR_POP are as follows.

Data type: REAL

• If the operand is character, the format is the default format for FLOAT.
• If the operand is numeric, date, or interval, the format is the same format as x.
• If the operand is a UDT, the format is the format for the data type to which the UDT is implicitly cast.
• For information on the default format of data types and an explanation of the formatting characters in the format, see “Data Type Formats and Format Phrases” in SQL Data Types and Literals.

Support for UDTs

By default, Teradata Database performs implicit type conversion on UDT arguments that have implicit casts that cast between the UDTs and any of the following predefined types:

• Numeric
• Character
• DATE
• Interval
• To define an implicit cast for a UDT, use the CREATE CAST statement and specify the AS ASSIGNMENT clause. For more information on CREATE CAST, see SQL Data Definition Language.

Implicit type conversion of UDTs for system operators and functions, including COVAR_POP, is a Teradata extension to the ANSI SQL standard. To disable this extension, set the DisableUDTImplCastForSysFuncOp field of the DBS Control Record to TRUE. For details, see Utilities: Volume 1 (A-K).

For more information on implicit type conversion of UDTs, see Chapter 13: “Data Type Conversions.”

COVAR_POP Window Function

For the COVAR_POP window function that performs a group, cumulative, or moving computation, see “Window Aggregate Functions” on page 984.