Exemples REGR_INTERCEPT
WITH RECURSIVE years(byyear) AS (
SELECT 1991 FROM rdb$database UNION ALL
SELECT byyear+1 FROM years WHERE byyear < 2020
),
s AS (
SELECT EXTRACT(YEAR FROM order_date) AS byyear,
SUM(total_value) AS total_value
FROM sales GROUP BY 1
),
regr AS (
SELECT REGR_INTERCEPT(total_value, byyear) as intercept,
REGR_SLOPE(total_value, byyear) as slope
FROM s)
SELECT years.byyear AS byyear,
intercept + (slope * years.byyear) AS total_value
FROM years CROSS JOIN regr
BYYEAR TOTAL_VALUE ---------------------------- 1991 118377,35 1992 414557,62 1993 710737,89 1994 1006918,16 1995 1303098,43 1996 1599278,69 1997 1895458,96 1998 2191639,23 1999 2487819,50 2000 2783999,77 ...