REGR_AVGY()
Overview
The REGR_AVGY()
aggregate function calculates the mean of the dependent variable (y) for non-null pairs of dependent (y) and independent (x) variables. This function is used in linear regression analysis to compute the average value of the dependent variable where both variables are not null.
Syntax
The syntax for this function is as follows:
Parameters
y
: variable being predictedx
: variable used for prediction
Example
For the needs of this section, we’re going to use a simplified version of the film
table from the Pagila database, containing only the title
, length
and rating
columns. The complete schema for the film
table can be found on the
Pagila database website.
They query below uses the REGR_AVGY()
function to calculate the mean of the dependent variable (rating
) for rows where both rating
and length
are not null:
By running the above query, we will get the following output: