REGR_AVGX

REGR_AVGX is a statistical function in SQL used to compute the average of the independent variable (typically denoted as "x") for selected database entries across a specific regression line. This function supports linear regression analysis within SQL analytical inquiries by helping to characterize the relationship between corresponding independent and dependent variable values.

REGR_AVGX(y, x)

  • y: This is the dependent variable parameter in the function REGR_AVGX(y, x). It represents the set of values that are to be predicted or estimated.
  • x: This is the independent variable parameter in the function REGR_AVGX(y, x). It is the set of values used for prediction or estimation of the dependent variable ‘y’.

Example

SELECT REGR_AVGX(y, x) FROM (VALUES (1, 2), (2, 4), (3, 6)) AS t(x, y);

Output

2

Explanation

The REGR_AVGX function calculates the average of the independent variable (x). In our example, with the input values for variable x being 1, 2, and 3, the average of these numbers equals 2.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.