CREATE OR REPLACE ATTRIBUTE DIMENSION sh_times_attr_dim
-- Classifications are metadata that can be used by applications. They are
-- not required by the database to create or query an analytic view object.
CLASSIFICATION caption VALUE 'Time'
CLASSIFICATION description VALUE 'Time'
-- The attribute dimension references the sh.times table.
USING sh.times
-- In this example, a list of columns from the sh.times table that will be used
-- by hierarchies and analytic views.
ATTRIBUTES
(time_id
CLASSIFICATION caption VALUE 'Day'
CLASSIFICATION description VALUE 'Day',
calendar_month_desc
CLASSIFICATION caption VALUE 'Calendar Month'
CLASSIFICATION description VALUE 'Calendar Month',
end_of_cal_month
CLASSIFICATION caption VALUE 'End of Calendar Month'
CLASSIFICATION description VALUE 'End of Calendar Month',
calendar_quarter_desc
CLASSIFICATION caption VALUE 'Calendar Quarter'
CLASSIFICATION description VALUE 'Calendar Quarter',
end_of_cal_quarter
CLASSIFICATION caption VALUE 'End of Calendar Quarter'
CLASSIFICATION description VALUE 'End of Calendar Quarter',
calendar_year
CLASSIFICATION caption VALUE 'Calendar Year'
CLASSIFICATION description VALUE 'Calendar Year',
end_of_cal_year
CLASSIFICATION caption VALUE 'End of Calendar Year'
CLASSIFICATION description VALUE 'End of Calendar Year',
fiscal_month_desc
CLASSIFICATION caption VALUE 'Fiscal Month'
CLASSIFICATION description VALUE 'Fiscal Month',
end_of_fis_month
CLASSIFICATION caption VALUE 'End of Fiscal Month'
CLASSIFICATION description VALUE 'End of Fiscal Month',
fiscal_quarter_desc
CLASSIFICATION caption VALUE 'Fiscal Quarter'
CLASSIFICATION description VALUE 'Calendar Quarter',
end_of_fis_quarter
CLASSIFICATION caption VALUE 'End of Fiscal Quarter'
CLASSIFICATION description VALUE 'End of Fiscal Quarter',
fiscal_year
CLASSIFICATION caption VALUE 'Fiscal Year'
CLASSIFICATION description VALUE 'Fiscal Year',
end_of_fis_year
CLASSIFICATION caption VALUE 'End of Fiscal Year'
CLASSIFICATION description VALUE 'End of Fiscal Year'
)
-- A grouping of values at the same level of aggregation.
LEVEL day
CLASSIFICATION caption VALUE 'Day'
CLASSIFICATION description VALUE 'Day'
-- Attribute with unique values for days.
KEY time_id
-- Can be used as a text description of the KEY attribute.
MEMBER NAME to_char(time_id)
-- Another text description.
MEMBER CAPTION to_char(time_id)
-- Another text description.
MEMBER DESCRIPTION to_char(time_id)
-- Default sort order of the level.
ORDER BY time_id
-- A list of attributes that are uniquely determined by the KEY attribute. That is,
-- for each value of the KEY attribute there is only one value of the determined
-- attribute.
DETERMINES(calendar_month_desc,fiscal_month_desc)
LEVEL calendar_month
CLASSIFICATION caption VALUE 'Calendar Month'
CLASSIFICATION description VALUE 'Calendar Month'
KEY calendar_month_desc
MEMBER NAME calendar_month_desc
MEMBER CAPTION calendar_month_desc
MEMBER DESCRIPTION calendar_month_desc
ORDER BY end_of_cal_month
DETERMINES(calendar_quarter_desc, end_of_cal_month)
LEVEL calendar_quarter
CLASSIFICATION caption VALUE 'Calendar Quarter'
CLASSIFICATION description VALUE 'Calendar Quarter'
KEY calendar_quarter_desc
MEMBER NAME calendar_quarter_desc
MEMBER CAPTION calendar_quarter_desc
MEMBER DESCRIPTION calendar_quarter_desc
ORDER BY end_of_cal_quarter
DETERMINES(calendar_year, end_of_cal_quarter)
LEVEL calendar_year
CLASSIFICATION caption VALUE 'Calendar Year'
CLASSIFICATION description VALUE 'Calendar Year'
KEY calendar_year
MEMBER NAME TO_CHAR(calendar_year)
MEMBER CAPTION TO_CHAR(calendar_year)
MEMBER DESCRIPTION TO_CHAR(calendar_year)
ORDER BY end_of_cal_year
DETERMINES (end_of_cal_year)
LEVEL fiscal_month
CLASSIFICATION caption VALUE 'Fiscal Month'
CLASSIFICATION description VALUE 'Fiscal Month'
KEY fiscal_month_desc
MEMBER NAME fiscal_month_desc
MEMBER CAPTION fiscal_month_desc
MEMBER DESCRIPTION fiscal_month_desc
ORDER BY end_of_fis_month
DETERMINES(fiscal_quarter_desc, end_of_fis_month)
LEVEL fiscal_quarter
CLASSIFICATION caption VALUE 'Fiscal Quarter'
CLASSIFICATION description VALUE 'Fiscal Quarter'
KEY fiscal_quarter_desc
MEMBER NAME fiscal_quarter_desc
MEMBER CAPTION fiscal_quarter_desc
MEMBER DESCRIPTION fiscal_quarter_desc
ORDER BY end_of_fis_quarter
DETERMINES(fiscal_year, end_of_fis_quarter)
LEVEL fiscal_year
CLASSIFICATION caption VALUE 'Fiscal Year'
CLASSIFICATION description VALUE 'Fiscal Year'
KEY fiscal_year
MEMBER NAME TO_CHAR(fiscal_year)
MEMBER CAPTION TO_CHAR(fiscal_year)
MEMBER DESCRIPTION TO_CHAR(fiscal_year)
ORDER BY end_of_fis_year
DETERMINES (end_of_fis_year)
-- The value of a single, top most hierarchy value.
ALL MEMBER NAME 'ALL YEARS';
View created.
CREATE OR REPLACE HIERARCHY sh_times_calendar_hier
CLASSIFICATION caption VALUE 'Calendar Year'
CLASSIFICATION description VALUE 'Calendar Year'
-- This hierarchy references the sh_times_attr_dim attribute dimension.
USING sh_times_attr_dim
-- A list of levels that make up an aggregation path.
(day CHILD OF
calendar_month CHILD OF
calendar_quarter CHILD OF
calendar_year)
Statement processed.
CREATE OR REPLACE HIERARCHY sh_times_fiscal_hier
CLASSIFICATION caption VALUE 'Fiscal Year'
CLASSIFICATION description VALUE 'Fiscal Year'
USING sh_times_attr_dim
(day CHILD OF
fiscal_month CHILD OF
fiscal_quarter CHILD OF
fiscal_year)
Statement processed.
CREATE OR REPLACE ATTRIBUTE DIMENSION sh_products_attr_dim
USING sh.products
ATTRIBUTES (
prod_id
CLASSIFICATION caption VALUE 'Product'
CLASSIFICATION description VALUE 'Product',
prod_name
CLASSIFICATION caption VALUE 'Product'
CLASSIFICATION description VALUE 'Product',
prod_subcategory
CLASSIFICATION caption VALUE 'Subcategory'
CLASSIFICATION description VALUE 'Subcategory',
prod_category
CLASSIFICATION caption VALUE 'Category'
CLASSIFICATION description VALUE 'Category'
)
LEVEL PRODUCT
CLASSIFICATION caption VALUE 'Product'
CLASSIFICATION description VALUE 'Product'
KEY prod_id
MEMBER NAME prod_name
MEMBER CAPTION prod_name
MEMBER DESCRIPTION prod_name
ORDER BY prod_name
DETERMINES (prod_subcategory)
LEVEL SUBCATEGORY
CLASSIFICATION caption VALUE 'Subcategory'
CLASSIFICATION description VALUE 'Subcategory'
KEY prod_subcategory
MEMBER NAME prod_subcategory
MEMBER CAPTION prod_subcategory
MEMBER DESCRIPTION prod_subcategory
ORDER BY prod_subcategory
DETERMINES (prod_category)
LEVEL CATEGORY
CLASSIFICATION caption VALUE 'Category'
CLASSIFICATION description VALUE 'Category'
KEY prod_category
MEMBER NAME prod_category
MEMBER CAPTION prod_category
MEMBER DESCRIPTION prod_category
ORDER BY prod_category
ALL MEMBER NAME 'ALL PRODUCTS'
Statement processed.
CREATE OR REPLACE HIERARCHY sh_products_hier
CLASSIFICATION caption VALUE 'Products'
CLASSIFICATION description VALUE 'Products'
USING sh_products_attr_dim
(product CHILD OF
subcategory CHILD OF
category)
Statement processed.
CREATE OR REPLACE VIEW sh_customers_dim_view AS
SELECT
a.cust_id,
a.cust_last_name || ', ' || a.cust_first_name as customer_name,
a.cust_city || ', ' || a.cust_state_province || ', ' || a.country_id as city_id,
a.cust_city as city_name,
a.cust_state_province || ', ' || a.country_id as state_province_id,
a.cust_state_province as state_province_name,
b.country_id,
b.country_name,
b.country_subregion as subregion,
b.country_region as region
FROM sh.customers a, sh.countries b
where a.country_id = b.country_id
View created.
SELECT *
FROM sh_customers_dim_view
WHERE rownum <= 50
ORDER BY region,
subregion,
country_name,
state_province_id,
city_id
CUST_ID | CUSTOMER_NAME | CITY_ID | CITY_NAME | STATE_PROVINCE_ID | STATE_PROVINCE_NAME | COUNTRY_ID | COUNTRY_NAME | SUBREGION | REGION |
---|---|---|---|---|---|---|---|---|---|
6784 | Kenney, Abner | Killarney, Kerry, 52772 | Killarney | Kerry, 52772 | Kerry | 52772 | Canada | Northern America | Americas |
21894 | Everett, Abner | Tralee, Kerry, 52772 | Tralee | Kerry, 52772 | Kerry | 52772 | Canada | Northern America | Americas |
43228 | Everett, Abner | Los Angeles, CA, 52790 | Los Angeles | CA, 52790 | CA | 52790 | United States of America | Northern America | Americas |
47006 | Everett, Abner | Montara, CA, 52790 | Montara | CA, 52790 | CA | 52790 | United States of America | Northern America | Americas |
31672 | Kenney, Abner | Pala, CA, 52790 | Pala | CA, 52790 | CA | 52790 | United States of America | Northern America | Americas |
12112 | Everett, Abner | Dolores, CO, 52790 | Dolores | CO, 52790 | CO | 52790 | United States of America | Northern America | Americas |
34359 | Robbinette, Abner | Haswell, CO, 52790 | Haswell | CO, 52790 | CO | 52790 | United States of America | Northern America | Americas |
37006 | Robbinette, Abner | Evinston, FL, 52790 | Evinston | FL, 52790 | FL | 52790 | United States of America | Northern America | Americas |
40561 | Robbinette, Abner | Noma, FL, 52790 | Noma | FL, 52790 | FL | 52790 | United States of America | Northern America | Americas |
13895 | Kenney, Abner | Palmdale, FL, 52790 | Palmdale | FL, 52790 | FL | 52790 | United States of America | Northern America | Americas |
21006 | Kenney, Abner | Saint Marks, FL, 52790 | Saint Marks | FL, 52790 | FL | 52790 | United States of America | Northern America | Americas |
16581 | Kenney, Abner | Mackville, KY, 52790 | Mackville | KY, 52790 | KY | 52790 | United States of America | Northern America | Americas |
13894 | Ruddy, Abigail | Joinville, Santa Catarina, 52775 | Joinville | Santa Catarina, 52775 | Santa Catarina | 52775 | Brazil | Southern America | Americas |
21005 | Ruddy, Abigail | Santos, Sao Paulo, 52775 | Santos | Sao Paulo, 52775 | Sao Paulo | 52775 | Brazil | Southern America | Americas |
17449 | Ruddy, Abigail | Nagoya, Aichi, 52782 | Nagoya | Aichi, 52782 | Aichi | 52782 | Japan | Asia | Asia |
24561 | Ruddy, Abigail | Yokohama, Kanagawa, 52782 | Yokohama | Kanagawa, 52782 | Kanagawa | 52782 | Japan | Asia | Asia |
49672 | Kenney, Abner | Nanterre, Ile-de-France, 52779 | Nanterre | Ile-de-France, 52779 | Ile-de-France | 52779 | France | Western Europe | Europe |
4117 | Everett, Abner | Clermont-l'Herault, Languedoc-Roussillon, 52779 | Clermont-l'Herault | Languedoc-Roussillon, 52779 | Languedoc-Roussillon | 52779 | France | Western Europe | Europe |
25451 | Everett, Abner | Heilbronn, Baden-Wuerttemberg, 52776 | Heilbronn | Baden-Wuerttemberg, 52776 | Baden-Wuerttemberg | 52776 | Germany | Western Europe | Europe |
46117 | Kenney, Abner | Ravensburg, Baden-Wuerttemberg, 52776 | Ravensburg | Baden-Wuerttemberg, 52776 | Baden-Wuerttemberg | 52776 | Germany | Western Europe | Europe |
7673 | Everett, Abner | Schwaebisch Gmuend, Baden-Wuerttemberg, 52776 | Schwaebisch Gmuend | Baden-Wuerttemberg, 52776 | Baden-Wuerttemberg | 52776 | Germany | Western Europe | Europe |
1451 | Robbinette, Abner | Schwaebisch Gmuend, Baden-Wuerttemberg, 52776 | Schwaebisch Gmuend | Baden-Wuerttemberg, 52776 | Baden-Wuerttemberg | 52776 | Germany | Western Europe | Europe |
25470 | Everett, Abner | Stuttgart, Baden-Wuerttemberg, 52776 | Stuttgart | Baden-Wuerttemberg, 52776 | Baden-Wuerttemberg | 52776 | Germany | Western Europe | Europe |
11228 | Everett, Abner | Ingolstadt, Bayern, 52776 | Ingolstadt | Bayern, 52776 | Bayern | 52776 | Germany | Western Europe | Europe |
39672 | Everett, Abner | Murnau, Bayern, 52776 | Murnau | Bayern, 52776 | Bayern | 52776 | Germany | Western Europe | Europe |
17450 | Kenney, Abner | Nuernberg, Bayern, 52776 | Nuernberg | Bayern, 52776 | Bayern | 52776 | Germany | Western Europe | Europe |
24562 | Kenney, Abner | Koeln, Nordrhein-Westfalen, 52776 | Koeln | Nordrhein-Westfalen, 52776 | Nordrhein-Westfalen | 52776 | Germany | Western Europe | Europe |
50561 | Everett, Abner | Neuss, Nordrhein-Westfalen, 52776 | Neuss | Nordrhein-Westfalen, 52776 | Nordrhein-Westfalen | 52776 | Germany | Western Europe | Europe |
5006 | Robbinette, Abner | Warstein, Nordrhein-Westfalen, 52776 | Warstein | Nordrhein-Westfalen, 52776 | Nordrhein-Westfalen | 52776 | Germany | Western Europe | Europe |
35227 | Ruddy, Abigail | Lelystad, Flevopolder, 52770 | Lelystad | Flevopolder, 52770 | Flevopolder | 52770 | Italy | Western Europe | Europe |
49671 | Ruddy, Abigail | Ede, Gelderland, 52770 | Ede | Gelderland, 52770 | Gelderland | 52770 | Italy | Western Europe | Europe |
6783 | Ruddy, Abigail | Schimmert, Limburg, 52770 | Schimmert | Limburg, 52770 | Limburg | 52770 | Italy | Western Europe | Europe |
18339 | Everett, Abner | Asten, Noord-Brabant, 52770 | Asten | Noord-Brabant, 52770 | Noord-Brabant | 52770 | Italy | Western Europe | Europe |
3229 | Kenney, Abner | Bergen op Zoom, Noord-Brabant, 52770 | Bergen op Zoom | Noord-Brabant, 52770 | Noord-Brabant | 52770 | Italy | Western Europe | Europe |
38784 | Kenney, Abner | Raamsdonksveer, Noord-Brabant, 52770 | Raamsdonksveer | Noord-Brabant, 52770 | Noord-Brabant | 52770 | Italy | Western Europe | Europe |
28117 | Kenney, Abner | Tilburg, Noord-Brabant, 52770 | Tilburg | Noord-Brabant, 52770 | Noord-Brabant | 52770 | Italy | Western Europe | Europe |
28116 | Ruddy, Abigail | Haarlem, Noord-Holland, 52770 | Haarlem | Noord-Holland, 52770 | Noord-Holland | 52770 | Italy | Western Europe | Europe |
3228 | Ruddy, Abigail | Hoofddorp, Noord-Holland, 52770 | Hoofddorp | Noord-Holland, 52770 | Noord-Holland | 52770 | Italy | Western Europe | Europe |
10338 | Ruddy, Abigail | Scheveningen, Zuid-Holland, 52770 | Scheveningen | Zuid-Holland, 52770 | Zuid-Holland | 52770 | Italy | Western Europe | Europe |
35228 | Kenney, Abner | Malaga, Malaga, 52778 | Malaga | Malaga, 52778 | Malaga | 52778 | Spain | Western Europe | Europe |
31671 | Ruddy, Abigail | Bolton, England - Greater Manchester, 52789 | Bolton | England - Greater Manchester, 52789 | England - Greater Manchester | 52789 | United Kingdom | Western Europe | Europe |
32561 | Everett, Abner | Didcot, England - Oxfordshire, 52789 | Didcot | England - Oxfordshire, 52789 | England - Oxfordshire | 52789 | United Kingdom | Western Europe | Europe |
44116 | Robbinette, Abner | Henley-on-Thames, England - Oxfordshire, 52789 | Henley-on-Thames | England - Oxfordshire, 52789 | England - Oxfordshire | 52789 | United Kingdom | Western Europe | Europe |
10339 | Kenney, Abner | Birmingham, England - West Midlands, 52789 | Birmingham | England - West Midlands, 52789 | England - West Midlands | 52789 | United Kingdom | Western Europe | Europe |
42339 | Kenney, Abner | Wolverhampton, England - West Midlands, 52789 | Wolverhampton | England - West Midlands, 52789 | England - West Midlands | 52789 | United Kingdom | Western Europe | Europe |
36117 | Everett, Abner | Wolverhampton, England - West Midlands, 52789 | Wolverhampton | England - West Midlands, 52789 | England - West Midlands | 52789 | United Kingdom | Western Europe | Europe |
29006 | Everett, Abner | Keighley, England - West Yorkshire, 52789 | Keighley | England - West Yorkshire, 52789 | England - West Yorkshire | 52789 | United Kingdom | Western Europe | Europe |
14784 | Everett, Abner | Belfast City, Northern Ireland - County Antr, 52789 | Belfast City | Northern Ireland - County Antr, 52789 | Northern Ireland - County Antr | 52789 | United Kingdom | Western Europe | Europe |
8561 | Robbinette, Abner | Belfast City, Northern Ireland - County Antr, 52789 | Belfast City | Northern Ireland - County Antr, 52789 | Northern Ireland - County Antr | 52789 | United Kingdom | Western Europe | Europe |
47895 | Robbinette, Abner | Barry, Wales - South Glamorgan, 52789 | Barry | Wales - South Glamorgan, 52789 | Wales - South Glamorgan | 52789 | United Kingdom | Western Europe | Europe |
CREATE OR REPLACE ATTRIBUTE DIMENSION sh_customers_attr_dim
USING sh_customers_dim_view
ATTRIBUTES (
cust_id
CLASSIFICATION caption VALUE 'Customer'
CLASSIFICATION description VALUE 'Customer',
customer_name
CLASSIFICATION caption VALUE 'Customer'
CLASSIFICATION description VALUE 'Customer',
city_id
CLASSIFICATION caption VALUE 'City'
CLASSIFICATION description VALUE 'City',
city_name
CLASSIFICATION caption VALUE 'City'
CLASSIFICATION description VALUE 'City',
state_province_id
CLASSIFICATION caption VALUE 'State Province'
CLASSIFICATION description VALUE 'State Province',
state_province_name
CLASSIFICATION caption VALUE 'State Province'
CLASSIFICATION description VALUE 'State Province',
country_id
CLASSIFICATION caption VALUE 'Country'
CLASSIFICATION description VALUE 'Country',
country_name
CLASSIFICATION caption VALUE 'Country'
CLASSIFICATION description VALUE 'Country',
subregion
CLASSIFICATION caption VALUE 'Subregion'
CLASSIFICATION description VALUE 'Subregion',
region
CLASSIFICATION caption VALUE 'Region'
CLASSIFICATION description VALUE 'Region'
)
LEVEL CUSTOMER
CLASSIFICATION caption VALUE 'Customer'
CLASSIFICATION description VALUE 'Customer'
KEY cust_id
MEMBER NAME customer_name
MEMBER CAPTION customer_name
MEMBER DESCRIPTION customer_name
ORDER BY customer_name
DETERMINES (city_id)
LEVEL CITY
CLASSIFICATION caption VALUE 'City'
CLASSIFICATION description VALUE 'City'
KEY city_id
MEMBER NAME city_name
MEMBER CAPTION city_name
MEMBER DESCRIPTION city_name
ORDER BY city_name
DETERMINES (state_province_id)
LEVEL STATE_PROVINCE
CLASSIFICATION caption VALUE 'State_Province'
CLASSIFICATION description VALUE 'State Province'
KEY state_province_id
MEMBER NAME state_province_name
MEMBER CAPTION state_province_name
MEMBER DESCRIPTION state_province_name
ORDER BY state_province_name
DETERMINES (country_id)
LEVEL COUNTRY
CLASSIFICATION caption VALUE 'Country'
CLASSIFICATION description VALUE 'Country'
KEY country_id
MEMBER NAME country_name
MEMBER CAPTION country_name
MEMBER DESCRIPTION country_name
ORDER BY country_name
DETERMINES (subregion)
LEVEL SUBREGION
CLASSIFICATION caption VALUE 'Subregion'
CLASSIFICATION description VALUE 'Subregion'
KEY subregion
MEMBER NAME subregion
MEMBER CAPTION subregion
MEMBER DESCRIPTION subregion
ORDER BY subregion
DETERMINES (region)
LEVEL REGION
CLASSIFICATION caption VALUE 'Region'
CLASSIFICATION description VALUE 'Region'
KEY region
MEMBER NAME region
MEMBER CAPTION region
MEMBER DESCRIPTION region
ORDER BY region
ALL MEMBER NAME 'ALL CUSTOMERS'
Statement processed.
CREATE OR REPLACE HIERARCHY sh_customers_hier
CLASSIFICATION caption VALUE 'Customers'
CLASSIFICATION description VALUE 'Customers'
USING sh_customers_attr_dim
(customer CHILD OF
city CHILD OF
state_province CHILD OF
country CHILD OF
subregion CHILD OF
region)
Statement processed.
CREATE OR REPLACE ATTRIBUTE DIMENSION sh_channels_attr_dim
CLASSIFICATION caption VALUE 'Channels'
CLASSIFICATION description VALUE 'Channels'
USING sh.channels
ATTRIBUTES (
channel_id
CLASSIFICATION caption VALUE 'Channel'
CLASSIFICATION description VALUE 'Channel',
channel_desc
CLASSIFICATION caption VALUE 'Channel'
CLASSIFICATION description VALUE 'Channel',
channel_class
CLASSIFICATION caption VALUE 'Channel Class'
CLASSIFICATION description VALUE 'Channel Class'
)
LEVEL CHANNEL
CLASSIFICATION caption VALUE 'Channel'
CLASSIFICATION description VALUE 'Channel'
KEY channel_id
MEMBER NAME channel_desc
MEMBER CAPTION channel_desc
ORDER BY channel_desc
DETERMINES (channel_class)
LEVEL CHANNEL_CLASS
CLASSIFICATION caption VALUE 'Channel_Class'
CLASSIFICATION description VALUE 'Channel Class'
KEY channel_class
MEMBER NAME channel_class
MEMBER CAPTION channel_class
ORDER BY channel_class
ALL MEMBER NAME 'ALL CHANNELS'
Statement processed.
CREATE OR REPLACE HIERARCHY sh_channels_hier
CLASSIFICATION caption VALUE 'Channels'
CLASSIFICATION description VALUE 'Channels'
USING sh_channels_attr_dim
(channel CHILD OF
channel_class)
Statement processed.
SELECT * FROM sh_channels_hier
CHANNEL_ID | CHANNEL_DESC | CHANNEL_CLASS | MEMBER_NAME | MEMBER_UNIQUE_NAME | MEMBER_CAPTION | MEMBER_DESCRIPTION | LEVEL_NAME | HIER_ORDER | DEPTH | IS_LEAF | PARENT_LEVEL_NAME | PARENT_UNIQUE_NAME |
---|---|---|---|---|---|---|---|---|---|---|---|---|
- | - | - | ALL CHANNELS | [ALL].[ALL CHANNELS] | - | - | ALL | 0 | 0 | 0 | - | - |
- | - | Direct | Direct | [CHANNEL_CLASS].&[Direct] | Direct | - | CHANNEL_CLASS | 1 | 1 | 0 | ALL | [ALL].[ALL CHANNELS] |
3 | Direct Sales | Direct | Direct Sales | [CHANNEL].&[3] | Direct Sales | - | CHANNEL | 2 | 2 | 1 | CHANNEL_CLASS | [CHANNEL_CLASS].&[Direct] |
9 | Tele Sales | Direct | Tele Sales | [CHANNEL].&[9] | Tele Sales | - | CHANNEL | 3 | 2 | 1 | CHANNEL_CLASS | [CHANNEL_CLASS].&[Direct] |
- | - | Indirect | Indirect | [CHANNEL_CLASS].&[Indirect] | Indirect | - | CHANNEL_CLASS | 4 | 1 | 0 | ALL | [ALL].[ALL CHANNELS] |
5 | Catalog | Indirect | Catalog | [CHANNEL].&[5] | Catalog | - | CHANNEL | 5 | 2 | 1 | CHANNEL_CLASS | [CHANNEL_CLASS].&[Indirect] |
4 | Internet | Indirect | Internet | [CHANNEL].&[4] | Internet | - | CHANNEL | 6 | 2 | 1 | CHANNEL_CLASS | [CHANNEL_CLASS].&[Indirect] |
- | - | Others | Others | [CHANNEL_CLASS].&[Others] | Others | - | CHANNEL_CLASS | 7 | 1 | 0 | ALL | [ALL].[ALL CHANNELS] |
2 | Partners | Others | Partners | [CHANNEL].&[2] | Partners | - | CHANNEL | 8 | 2 | 1 | CHANNEL_CLASS | [CHANNEL_CLASS].&[Others] |
SELECT * from sh.promotions
PROMO_ID | PROMO_NAME | PROMO_SUBCATEGORY | PROMO_SUBCATEGORY_ID | PROMO_CATEGORY | PROMO_CATEGORY_ID | PROMO_COST | PROMO_BEGIN_DATE | PROMO_END_DATE | PROMO_TOTAL | PROMO_TOTAL_ID |
---|---|---|---|---|---|---|---|---|---|---|
999 | NO PROMOTION # | NO RPOMOTION | 11 | NO PROMOTION | 2 | 0 | 01-JAN-99 | 01-JAN-99 | Promotion total | 1 |
108 | newspaper promotion #16-108 | ad news | 16 | newspaper | 8 | 200 | 23-DEC-00 | 23-JAN-01 | Promotion total | 1 |
232 | post promotion #20-232 | downtown billboard | 20 | post | 9 | 300 | 25-SEP-98 | 25-NOV-98 | Promotion total | 1 |
349 | newspaper promotion #16-349 | ad news | 16 | newspaper | 8 | 400 | 10-JUL-98 | 10-SEP-98 | Promotion total | 1 |
471 | internet promotion #14-471 | ad | 14 | internet | 6 | 600 | 26-FEB-00 | 26-MAR-00 | Promotion total | 1 |
448 | TV promotion #13-448 | TV program sponsorship | 13 | TV | 3 | 1100 | 06-AUG-00 | 06-SEP-00 | Promotion total | 1 |
86 | internet promotion #25-86 | loyal customer discount | 25 | internet | 6 | 1400 | 20-SEP-98 | 20-NOV-98 | Promotion total | 1 |
49 | TV promotion #12-49 | TV commercial | 12 | TV | 3 | 1500 | 10-AUG-00 | 10-SEP-00 | Promotion total | 1 |
166 | post promotion #21-166 | freeway billboard | 21 | post | 9 | 2000 | 25-SEP-98 | 25-NOV-98 | Promotion total | 1 |
210 | newspaper promotion #19-210 | coupon news | 19 | newspaper | 8 | 2100 | 19-MAR-99 | 19-JUN-99 | Promotion total | 1 |
282 | post promotion #20-282 | downtown billboard | 20 | post | 9 | 2300 | 06-DEC-00 | 06-JAN-01 | Promotion total | 1 |
327 | newspaper promotion #16-327 | ad news | 16 | newspaper | 8 | 2800 | 09-APR-99 | 09-JUL-99 | Promotion total | 1 |
289 | internet promotion #29-289 | online discount | 29 | internet | 6 | 3000 | 01-NOV-98 | 01-JAN-99 | Promotion total | 1 |
252 | TV promotion #12-252 | TV commercial | 12 | TV | 3 | 3100 | 20-JUN-98 | 20-AUG-98 | Promotion total | 1 |
258 | magazine promotion #26-258 | manufacture rebate magazine | 26 | magazine | 7 | 3200 | 04-MAY-00 | 04-JUN-00 | Promotion total | 1 |
528 | internet promotion #29-528 | online discount | 29 | internet | 6 | 3400 | 15-DEC-00 | 15-JAN-01 | Promotion total | 1 |
324 | newspaper promotion #16-324 | ad news | 16 | newspaper | 8 | 3600 | 17-FEB-00 | 17-MAR-00 | Promotion total | 1 |
406 | radio promotion #32-406 | radio program sponsorship | 32 | radio | 10 | 4000 | 11-SEP-98 | 11-NOV-98 | Promotion total | 1 |
84 | newspaper promotion #19-84 | coupon news | 19 | newspaper | 8 | 4100 | 27-JAN-99 | 27-APR-99 | Promotion total | 1 |
449 | post promotion #20-449 | downtown billboard | 20 | post | 9 | 4200 | 10-NOV-98 | 10-JAN-99 | Promotion total | 1 |
308 | internet promotion #25-308 | loyal customer discount | 25 | internet | 6 | 4300 | 23-DEC-00 | 23-JAN-01 | Promotion total | 1 |
412 | newspaper promotion #19-412 | coupon news | 19 | newspaper | 8 | 4500 | 03-JUN-98 | 03-AUG-98 | Promotion total | 1 |
82 | TV promotion #13-82 | TV program sponsorship | 13 | TV | 3 | 4800 | 06-DEC-00 | 06-JAN-01 | Promotion total | 1 |
152 | newspaper promotion #27-152 | manufacture rebate news | 27 | newspaper | 8 | 5100 | 12-FEB-00 | 12-MAR-00 | Promotion total | 1 |
224 | TV promotion #13-224 | TV program sponsorship | 13 | TV | 3 | 5200 | 02-AUG-00 | 02-SEP-00 | Promotion total | 1 |
88 | post promotion #21-88 | freeway billboard | 21 | post | 9 | 5400 | 07-AUG-00 | 07-SEP-00 | Promotion total | 1 |
266 | internet promotion #29-266 | online discount | 29 | internet | 6 | 5500 | 13-JUN-98 | 13-AUG-98 | Promotion total | 1 |
479 | TV promotion #13-479 | TV program sponsorship | 13 | TV | 3 | 5700 | 17-MAR-99 | 17-JUN-99 | Promotion total | 1 |
497 | newspaper promotion #16-497 | ad news | 16 | newspaper | 8 | 5900 | 25-MAR-99 | 25-JUN-99 | Promotion total | 1 |
407 | post promotion #20-407 | downtown billboard | 20 | post | 9 | 6100 | 16-APR-99 | 16-JUL-99 | Promotion total | 1 |
199 | post promotion #21-199 | freeway billboard | 21 | post | 9 | 6400 | 13-JUN-98 | 13-AUG-98 | Promotion total | 1 |
403 | magazine promotion #26-403 | manufacture rebate magazine | 26 | magazine | 7 | 6500 | 17-JUL-98 | 17-SEP-98 | Promotion total | 1 |
91 | internet promotion #29-91 | online discount | 29 | internet | 6 | 6600 | 03-AUG-00 | 03-SEP-00 | Promotion total | 1 |
268 | post promotion #17-268 | billboard | 17 | post | 9 | 6800 | 18-DEC-00 | 18-JAN-01 | Promotion total | 1 |
387 | TV promotion #13-387 | TV program sponsorship | 13 | TV | 3 | 7100 | 24-OCT-99 | 24-JAN-00 | Promotion total | 1 |
206 | magazine promotion #18-206 | coupon magazine | 18 | magazine | 7 | 7200 | 11-SEP-98 | 11-NOV-98 | Promotion total | 1 |
367 | TV promotion #13-367 | TV program sponsorship | 13 | TV | 3 | 7300 | 17-AUG-00 | 17-SEP-00 | Promotion total | 1 |
48 | newspaper promotion #19-48 | coupon news | 19 | newspaper | 8 | 7600 | 06-APR-99 | 06-JUL-99 | Promotion total | 1 |
426 | TV promotion #13-426 | TV program sponsorship | 13 | TV | 3 | 7700 | 02-JUN-98 | 02-AUG-98 | Promotion total | 1 |
78 | newspaper promotion #19-78 | coupon news | 19 | newspaper | 8 | 7800 | 21-MAY-00 | 21-JUN-00 | Promotion total | 1 |
118 | TV promotion #13-118 | TV program sponsorship | 13 | TV | 3 | 7900 | 12-MAY-00 | 12-JUN-00 | Promotion total | 1 |
212 | TV promotion #12-212 | TV commercial | 12 | TV | 3 | 8100 | 03-JUN-98 | 03-AUG-98 | Promotion total | 1 |
325 | magazine promotion #18-325 | coupon magazine | 18 | magazine | 7 | 8200 | 14-FEB-00 | 14-MAR-00 | Promotion total | 1 |
297 | post promotion #21-297 | freeway billboard | 21 | post | 9 | 8300 | 15-JAN-99 | 15-APR-99 | Promotion total | 1 |
368 | newspaper promotion #27-368 | manufacture rebate news | 27 | newspaper | 8 | 8700 | 18-NOV-98 | 18-JAN-99 | Promotion total | 1 |
59 | post promotion #20-59 | downtown billboard | 20 | post | 9 | 8800 | 02-FEB-00 | 02-MAR-00 | Promotion total | 1 |
264 | TV promotion #13-264 | TV program sponsorship | 13 | TV | 3 | 8900 | 15-MAR-99 | 15-JUN-99 | Promotion total | 1 |
532 | TV promotion #30-532 | promotion movie | 30 | TV | 3 | 9400 | 18-SEP-98 | 18-NOV-98 | Promotion total | 1 |
322 | internet promotion #14-322 | ad | 14 | internet | 6 | 9600 | 01-JUL-98 | 01-SEP-98 | Promotion total | 1 |
337 | TV promotion #13-337 | TV program sponsorship | 13 | TV | 3 | 9700 | 08-JAN-99 | 08-APR-99 | Promotion total | 1 |
CREATE OR REPLACE ATTRIBUTE DIMENSION sh_promotions_attr_dim
CLASSIFICATION caption VALUE 'Promotions'
CLASSIFICATION description VALUE 'Promotions'
USING sh.promotions
ATTRIBUTES (
promo_id
CLASSIFICATION caption VALUE 'promotion'
CLASSIFICATION description VALUE 'promotion',
promo_name
CLASSIFICATION caption VALUE 'promotion'
CLASSIFICATION description VALUE 'promotion',
promo_subcategory
CLASSIFICATION caption VALUE 'Subcategory'
CLASSIFICATION description VALUE 'Subcategory',
promo_category
CLASSIFICATION caption VALUE 'Category'
CLASSIFICATION description VALUE 'Category'
)
LEVEL PROMOTION
CLASSIFICATION caption VALUE 'promotion'
CLASSIFICATION description VALUE 'promotion'
KEY promo_id
MEMBER NAME promo_name
MEMBER CAPTION promo_name
ORDER BY promo_name
DETERMINES (promo_subcategory)
LEVEL SUBCATEGORY
CLASSIFICATION caption VALUE 'Subcategory'
CLASSIFICATION description VALUE 'Subcategory'
KEY promo_subcategory
MEMBER NAME promo_subcategory
MEMBER CAPTION promo_subcategory
ORDER BY promo_subcategory
DETERMINES (promo_category)
LEVEL CATEGORY
CLASSIFICATION caption VALUE 'Category'
CLASSIFICATION description VALUE 'Category'
KEY promo_category
MEMBER NAME promo_category
MEMBER CAPTION promo_category
ORDER BY promo_category
ALL MEMBER NAME 'ALL PROMOTIONS'
Statement processed.
CREATE OR REPLACE HIERARCHY sh_promotions_hier
CLASSIFICATION caption VALUE 'Promotions'
CLASSIFICATION description VALUE 'Promotions'
USING sh_promotions_attr_dim
(promotion CHILD OF
subcategory CHILD OF
category)
Statement processed.
CREATE OR REPLACE ANALYTIC VIEW sh_sales_history_av
CLASSIFICATION caption VALUE 'Sales History (SH Sample Schema)'
CLASSIFICATION description VALUE 'Sales History by Time, Product, Customer, Channel and Promotion'
-- The analytic view references data in the sh.sales fact table.
USING sh.sales
-- The list of attribute dimensions and hierarchies.
DIMENSION BY
(
sh_times_attr_dim
-- The join between attribute dimension and the fact table.
KEY time_id REFERENCES time_id
-- Hierarchies that will be used by this analytic view. May be all hierarchies of
-- the attribute dimension or a subset of hierarchies.
HIERARCHIES (sh_times_calendar_hier DEFAULT, sh_times_fiscal_hier),
sh_products_attr_dim
KEY prod_id REFERENCES prod_id
HIERARCHIES (sh_products_hier DEFAULT),
sh_customers_attr_dim
KEY cust_id REFERENCES cust_id
HIERARCHIES (sh_customers_hier DEFAULT),
sh_channels_attr_dim
KEY channel_id REFERENCES channel_id
HIERARCHIES (sh_channels_hier DEFAULT),
sh_promotions_attr_dim
KEY promo_id REFERENCES promo_id
HIERARCHIES (sh_promotions_hier DEFAULT)
)
MEASURES (
-- Amount sold maps to the fact table.
amount_sold FACT amount_sold
CLASSIFICATION caption VALUE 'Amount Sold'
CLASSIFICATION description VALUE 'Amount Sold'
CLASSIFICATION format_string VALUE '999,999,999,999.99',
-- Quantity sold maps to the fact table.
quantity_sold FACT quantity_sold
CLASSIFICATION caption VALUE 'Quantity Sold'
CLASSIFICATION description VALUE 'Quantity Sold'
CLASSIFICATION format_string VALUE '999,999,999,999',
-- Ratio of amount sold for the current value to the parent product value.
amt_sold_shr_parent_prod AS (SHARE_OF(amount_sold HIERARCHY sh_products_hier PARENT))
CLASSIFICATION caption VALUE 'Sales Product Share of Parent'
CLASSIFICATION description VALUE 'Sales Product Share of Parent'
CLASSIFICATION format_string VALUE '999.99',
-- Ratio of amount sold for the current value to the parent customer value.
sales_shr_parent_cust AS (SHARE_OF(amount_sold HIERARCHY sh_customers_hier PARENT))
CLASSIFICATION caption VALUE 'Sales Customer Share of Parent'
CLASSIFICATION description VALUE 'Sales Customer Share of Parent'
CLASSIFICATION format_string VALUE '999,999,999,999.99',
--
-- Calendar Year measures
--
-- Sales Calendar Year to Date
sales_cal_ytd AS (SUM(amount_sold) OVER (HIERARCHY sh_times_calendar_hier BETWEEN UNBOUNDED PRECEDING AND CURRENT MEMBER WITHIN ANCESTOR AT LEVEL calendar_year))
CLASSIFICATION caption VALUE 'Sales Calendar YTD'
CLASSIFICATION description VALUE 'Sales Calendar YTD'
CLASSIFICATION format_string VALUE '999,999,999,999.99',
-- Sales same period 1 year ago.
sales_cal_year_ago as (LAG(amount_sold) OVER (HIERARCHY sh_times_calendar_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL calendar_year))
CLASSIFICATION caption VALUE 'Sales Calendar Year Ago'
CLASSIFICATION description VALUE 'Sales Year Ago'
CLASSIFICATION format_string VALUE '$999,999,999,999.99',
-- Change in sales for the current period as compared to the same period 1 year ago.
sales_chg_cal_year_ago as (LAG_DIFF(amount_sold) OVER (HIERARCHY sh_times_calendar_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL calendar_year))
CLASSIFICATION caption VALUE 'Sales Change Calendar Year Ago'
CLASSIFICATION description VALUE 'Sales Change Calendar Year Ago'
CLASSIFICATION format_string VALUE '$999,999,999,999.99',
-- Percent change in sales for the current period as compared to the same period 1 year ago.
sales_pctchg_cal_year_ago as (LAG_DIFF_PERCENT(amount_sold) OVER (HIERARCHY sh_times_calendar_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL calendar_year))
CLASSIFICATION caption VALUE 'Sales Percent Change Calendar Year Ago'
CLASSIFICATION description VALUE 'Sales Percent Change Calendar Year Ago'
CLASSIFICATION format_string VALUE '999.99',
--
-- Fiscal Year measures
--
sales_fis_ytd AS (SUM(amount_sold) OVER (HIERARCHY sh_times_fiscal_hier BETWEEN UNBOUNDED PRECEDING AND CURRENT MEMBER WITHIN ANCESTOR AT LEVEL fiscal_year))
CLASSIFICATION caption VALUE 'Sales Fiscal YTD'
CLASSIFICATION description VALUE 'Sales Fiscal YTD'
CLASSIFICATION format_string VALUE '999,999,999,999.99',
sales_fis_year_ago as (LAG(amount_sold) OVER (HIERARCHY sh_times_fiscal_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL fiscal_year))
CLASSIFICATION caption VALUE 'Sales Fiscal Year Ago'
CLASSIFICATION description VALUE 'Sales Fiscal Year Ago'
CLASSIFICATION format_string VALUE '$999,999,999,999.99',
-- Change in sales for the current period as compared to the same period 1 year ago.
sales_chg_fis_year_ago as (LAG_DIFF(amount_sold) OVER (HIERARCHY sh_times_fiscal_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL fiscal_year))
CLASSIFICATION caption VALUE 'Sales Change Fiscal Year Ago'
CLASSIFICATION description VALUE 'Sales Change Fiscal Year Ago'
CLASSIFICATION format_string VALUE '$999,999,999,999.99',
-- Percent change in sales for the current period as compared to the same period 1 year ago.
sales_pctchg_fis_year_ago as (LAG_DIFF_PERCENT(amount_sold) OVER (HIERARCHY sh_times_fiscal_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL fiscal_year))
CLASSIFICATION caption VALUE 'Sales Percent Change Fiscal Year Ago'
CLASSIFICATION description VALUE 'Sales Percent Change Fiscal Year Ago'
CLASSIFICATION format_string VALUE '999.99'
)
DEFAULT MEASURE amount_sold
View created.