Team Fly 

Page 357

Lines

Important Points

3–9

Define an in-line select that will be the source for the query. It is basically the same query we started with before the model clause.

10

Specifies that we are only going to look at 'Direct Sales' channels.

11

Specifies the model clause.

12

Specifies the partition by clause (in this case, channel_desc).

13

Specifies the dimension by clause (here, prod_category and year). These elements will fully qualify the measure within the channel_desc partition.

14

Specifies the measures clause (quantity_sold).

15–16

Specify the rules clause—that is, calculations we want to perform on the measure. In this example, we are referring to a specific cell of quantity_sold, described by the dimensions prod_category (Hardware) and year (2002).

TABLE 9-18. Explanation of model Clause Syntax

Following are the results of the previous query. Notice that a new row has been added for Hardware in 2002. Its quantity_sold is 2638.9, which is the previous year's value (2399) plus 10 percent.

CHANNEL_DESC     PROD_CATEGORY                    YEAR QUANTITY_SOLD
---------------- ------------------------------ ------ -------------
Direct Sales     Electronics                      1998          7758
Direct Sales     Electronics                      1999         15007
...
Direct Sales     Hardware                         2000          1970
Direct Sales     Hardware                         2001          2399
Direct Sales     Hardware                         2002        2638.9
Direct Sales     Peripherals and Accessories      1998         44258
...
Direct Sales     Software/Other                   2000         64483
Direct Sales     Software/Other                   2001         49146
Team Fly 
0376