Skip to content

Model clause

SELECT SUBSTR(country,1,20) country, 
   SUBSTR(prod,1,15) prod, year, sales, growth
FROM sales_view
WHERE country='Italy'
MODEL RETURN UPDATED ROWS 
   PARTITION BY (country) 
   DIMENSION BY (prod, year)
   MEASURES (sale sales, 0 growth)
   RULES (
   growth[prod in ('Bounce','Y Box','Mouse Pad'), year between 1998 and 2001] =
   100* (sales[cv(prod), cv(year)] - 
   sales[cv(prod), cv(year) -1] ) / 
   sales[cv(prod), cv(year) -1] )
ORDER BY country, prod, year

DIMENSION BY

it should be possible to uniquely identify a row.

MEASURES

The data in colums defined in the MEASURES, can by modify by rules

drop table  tq84_model_clause ;
create table tq84_model_clause (
    row_      number,
    col_1     number,
    col_2     number,
    col_3     number,
    col_4     number,
    col_5     number
);

insert into tq84_model_clause values (1, 14,  2,  3,    4,  5);
insert into tq84_model_clause values (2,  3,  8,  7,   22,  2);
insert into tq84_model_clause values (3,  2,  4, 11,    5,  5);
insert into tq84_model_clause values (4,  9, 13,  3,    8,  1);
insert into tq84_model_clause values (5, 10,  2,  0, null,  3);
insert into tq84_model_clause values (6,  1,  2,  3,    4,  5);
commit;