Chapter 3. DB2 UDB’s statistics, analytic, and OLAP functions 117
Example 3-11 Linear regression example 4
SELECT
REGR_COUNT(t.sales, t.ad_budget) AS num_cities,
REGR_SLOPE(t.sales, t.ad_budget) AS a,
REGR_ICPT(t.sales, t.ad_budget) AS b,
REGR_R2(t.sales, t.ad_budget) as rsquared
FROM t
The result of this query is as follows. It shows R
2
to be 0.95917, which is a very
high quality of fit of the regression line.
num_cities a b rsquared
---------- ------ ------ ---------
128 1.9533 13.381 0.95917
3.3 OLAP functions
OLAP is “a category of software technology hat enables analysts, managers and
executives to gain insight into data through fast, consistent, interactive access to
a wide variety of possible views of information that has been transformed from
raw data to reflect the real dimensionality of the enterprise as understood by the
user”.
3
Typical enterprise dimensions are time, location/geography, product and
customer.
While OLAP systems have the ability to answer “who” and “what” questions, it is
their ability to answer “what if” and “why” that sets it apart from data warehouses.
OLAP enables decision making about future actions.
Important: DB2 supports non-linear regression models involving a single
independent variable. For example,
y = a
x
2
+ b
Restriction: We do not support regression models involving more than one
independent variable. For example,
y = a
1
x
1
+ a
2
x
2
+ .......a
n
x
n
+ b
3
BI Certification Guide (SG24-5747)