REGR_INTERCEPT()
Overview
The REGR_INTERCEPT()
aggregate function calculates the y-intercept of the univariate linear regression line for a group of data points, where the dependent variable is (y) and the independent variable is (x). The intercept is the point where the regression line crosses the y-axis when x=0.
Syntax
The syntax for this function is as follows:
Parameters
y
: variable being predictedx
: variable used for prediction
Example
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.
The above query uses the REGR_INTERCEPT()
function to calculate the y-intercept of the regression line for valid pairs of rating
and length
:
By running the code above we will get the following output: