Quellcode durchsuchen

Remove old sample-queries directory.

cartershanklin vor 11 Jahren
Ursprung
Commit
8f9c81efa7
53 geänderte Dateien mit 0 neuen und 2207 gelöschten Zeilen
  1. 0 4
      sample-queries/README.md
  2. 0 33
      sample-queries/query12.sql
  3. 0 52
      sample-queries/query13.sql
  4. 0 20
      sample-queries/query15.sql
  5. 0 45
      sample-queries/query17.sql
  6. 0 32
      sample-queries/query18.sql
  7. 0 26
      sample-queries/query19.sql
  8. 0 27
      sample-queries/query20.sql
  9. 0 27
      sample-queries/query21.sql
  10. 0 20
      sample-queries/query22.sql
  11. 0 19
      sample-queries/query26.sql
  12. 0 23
      sample-queries/query27.sql
  13. 0 50
      sample-queries/query28.sql
  14. 0 25
      sample-queries/query3.sql
  15. 0 20
      sample-queries/query32.sql
  16. 0 74
      sample-queries/query34.sql
  17. 0 38
      sample-queries/query39.sql
  18. 0 27
      sample-queries/query40.sql
  19. 0 22
      sample-queries/query42.sql
  20. 0 20
      sample-queries/query43.sql
  21. 0 18
      sample-queries/query45.sql
  22. 0 90
      sample-queries/query46.sql
  23. 0 68
      sample-queries/query48.sql
  24. 0 130
      sample-queries/query49.sql
  25. 0 60
      sample-queries/query50.sql
  26. 0 23
      sample-queries/query52.sql
  27. 0 15
      sample-queries/query55.sql
  28. 0 50
      sample-queries/query58.sql
  29. 0 98
      sample-queries/query64.sql
  30. 0 222
      sample-queries/query66.sql
  31. 0 45
      sample-queries/query67.sql
  32. 0 56
      sample-queries/query68.sql
  33. 0 22
      sample-queries/query7.sql
  34. 0 31
      sample-queries/query70.sql
  35. 0 41
      sample-queries/query71.sql
  36. 0 33
      sample-queries/query72.sql
  37. 0 42
      sample-queries/query73.sql
  38. 0 24
      sample-queries/query76.sql
  39. 0 51
      sample-queries/query79.sql
  40. 0 21
      sample-queries/query84.sql
  41. 0 82
      sample-queries/query85.sql
  42. 0 36
      sample-queries/query87.sql
  43. 0 94
      sample-queries/query88.sql
  44. 0 29
      sample-queries/query89.sql
  45. 0 22
      sample-queries/query90.sql
  46. 0 32
      sample-queries/query91.sql
  47. 0 24
      sample-queries/query92.sql
  48. 0 18
      sample-queries/query93.sql
  49. 0 22
      sample-queries/query94.sql
  50. 0 30
      sample-queries/query95.sql
  51. 0 16
      sample-queries/query96.sql
  52. 0 24
      sample-queries/query97.sql
  53. 0 34
      sample-queries/query98.sql

+ 0 - 4
sample-queries/README.md

@@ -1,4 +0,0 @@
-Sample TPC-DS Queries
-=====================
-
-This directory contains sample TPC-DS queries you can run once you have generated your data. Queries are compatible with Apache Hive 11 and up.

+ 0 - 33
sample-queries/query12.sql

@@ -1,33 +0,0 @@
-select  i_item_desc 
-      ,i_category 
-      ,i_class 
-      ,i_current_price
-      ,i_item_id
-      ,sum(ws_ext_sales_price) as itemrevenue 
-      ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price)) over
-          (partition by i_class) as revenueratio
-from	
-	web_sales
-    	,item 
-    	,date_dim
-where 
-	web_sales.ws_item_sk = item.i_item_sk 
-  	and item.i_category in ('Jewelry', 'Sports', 'Books')
-  	and web_sales.ws_sold_date_sk = date_dim.d_date_sk
-	and date_dim.d_date between '2001-01-12' and '2001-02-11'
-	and ws_sold_date between '2001-01-12' and '2001-02-11'
-group by 
-	i_item_id
-        ,i_item_desc 
-        ,i_category
-        ,i_class
-        ,i_current_price
-order by 
-	i_category
-        ,i_class
-        ,i_item_id
-        ,i_item_desc
-        ,revenueratio
-limit 100;
-
-

+ 0 - 52
sample-queries/query13.sql

@@ -1,52 +0,0 @@
-select avg(ss_quantity)
-       ,avg(ss_ext_sales_price)
-       ,avg(ss_ext_wholesale_cost)
-       ,sum(ss_ext_wholesale_cost)
- from store_sales
-     ,store
-     ,customer_demographics
-     ,household_demographics
-     ,customer_address
-     ,date_dim
- where store.s_store_sk = store_sales.ss_store_sk
- and  store_sales.ss_sold_date_sk = date_dim.d_date_sk and date_dim.d_year = 2001
- and ss_sold_date between '2001-01-01' and '2001-12-31'
- and((store_sales.ss_hdemo_sk=household_demographics.hd_demo_sk
-  and customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk
-  and customer_demographics.cd_marital_status = 'M'
-  and customer_demographics.cd_education_status = '4 yr Degree'
-  and store_sales.ss_sales_price between 100.00 and 150.00
-  and household_demographics.hd_dep_count = 3   
-     )or
-     (store_sales.ss_hdemo_sk=household_demographics.hd_demo_sk
-  and customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk
-  and customer_demographics.cd_marital_status = 'D'
-  and customer_demographics.cd_education_status = 'Primary'
-  and store_sales.ss_sales_price between 50.00 and 100.00   
-  and household_demographics.hd_dep_count = 1
-     ) or 
-     (store_sales.ss_hdemo_sk=household_demographics.hd_demo_sk
-  and customer_demographics.cd_demo_sk = ss_cdemo_sk
-  and customer_demographics.cd_marital_status = 'U'
-  and customer_demographics.cd_education_status = 'Advanced Degree'
-  and store_sales.ss_sales_price between 150.00 and 200.00 
-  and household_demographics.hd_dep_count = 1  
-     ))
- and((store_sales.ss_addr_sk = customer_address.ca_address_sk
-  and customer_address.ca_country = 'United States'
-  and customer_address.ca_state in ('KY', 'GA', 'NM')
-  and store_sales.ss_net_profit between 100 and 200  
-     ) or
-     (store_sales.ss_addr_sk = customer_address.ca_address_sk
-  and customer_address.ca_country = 'United States'
-  and customer_address.ca_state in ('MT', 'OR', 'IN')
-  and store_sales.ss_net_profit between 150 and 300  
-     ) or
-     (store_sales.ss_addr_sk = customer_address.ca_address_sk
-  and customer_address.ca_country = 'United States'
-  and customer_address.ca_state in ('WI', 'MO', 'WV')
-  and store_sales.ss_net_profit between 50 and 250  
-     ))
-;
-
-

+ 0 - 20
sample-queries/query15.sql

@@ -1,20 +0,0 @@
-select  ca_zip
-       ,sum(cs_sales_price)
- from catalog_sales
-     ,customer
-     ,customer_address
-     ,date_dim
- where catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
- 	and customer.c_current_addr_sk = customer_address.ca_address_sk 
- 	and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475',
-                                   '85392', '85460', '80348', '81792')
- 	      or customer_address.ca_state in ('CA','WA','GA')
- 	      or catalog_sales.cs_sales_price > 500)
- 	and catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
- 	and date_dim.d_qoy = 2 and date_dim.d_year = 2000
-	and cs_sold_date between '2000-04-01' and '2000-06-30'
- group by ca_zip
- order by ca_zip
- limit 100;
-
-

+ 0 - 45
sample-queries/query17.sql

@@ -1,45 +0,0 @@
-select  i_item_id
-       ,i_item_desc
-       ,s_state
-       ,count(ss_quantity) as store_sales_quantitycount
-       ,avg(ss_quantity) as store_sales_quantityave
-       ,stddev_samp(ss_quantity) as store_sales_quantitystdev
-       ,stddev_samp(ss_quantity)/avg(ss_quantity) as store_sales_quantitycov
-       ,count(sr_return_quantity) as_store_returns_quantitycount
-       ,avg(sr_return_quantity) as_store_returns_quantityave
-       ,stddev_samp(sr_return_quantity) as_store_returns_quantitystdev
-       ,stddev_samp(sr_return_quantity)/avg(sr_return_quantity) as store_returns_quantitycov
-       ,count(cs_quantity) as catalog_sales_quantitycount ,avg(cs_quantity) as catalog_sales_quantityave
-       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitystdev
-       ,stddev_samp(cs_quantity)/avg(cs_quantity) as catalog_sales_quantitycov
- from store_sales
-     ,store_returns
-     ,catalog_sales
-     ,date_dim d1
-     ,date_dim d2
-     ,date_dim d3
-     ,store
-     ,item
- where d1.d_quarter_name = '2000Q1'
-   and d1.d_date_sk = store_sales.ss_sold_date_sk
-   and ss_sold_date between '2000-01-01' and '2000-03-31'
-   and item.i_item_sk = store_sales.ss_item_sk
-   and store.s_store_sk = store_sales.ss_store_sk
-   and store_sales.ss_customer_sk = store_returns.sr_customer_sk
-   and store_sales.ss_item_sk = store_returns.sr_item_sk
-   and store_sales.ss_ticket_number = store_returns.sr_ticket_number
-   and store_returns.sr_returned_date_sk = d2.d_date_sk
-   and d2.d_quarter_name in ('2000Q1','2000Q2','2000Q3')
-   and sr_returned_date between '2000-01-01' and '2000-09-01'
-   and store_returns.sr_customer_sk = catalog_sales.cs_bill_customer_sk
-   and store_returns.sr_item_sk = catalog_sales.cs_item_sk
-   and catalog_sales.cs_sold_date_sk = d3.d_date_sk
-   and d3.d_quarter_name in ('2000Q1','2000Q2','2000Q3')
-   and cs_sold_date between '2000-01-01' and '2000-09-31'
- group by i_item_id
-         ,i_item_desc
-         ,s_state
- order by i_item_id
-         ,i_item_desc
-         ,s_state
-limit 100;

+ 0 - 32
sample-queries/query18.sql

@@ -1,32 +0,0 @@
-select  i_item_id,
-        ca_country,
-        ca_state, 
-        ca_county,
-        avg( cast(cs_quantity as decimal(12,2))) agg1,
-        avg( cast(cs_list_price as decimal(12,2))) agg2,
-        avg( cast(cs_coupon_amt as decimal(12,2))) agg3,
-        avg( cast(cs_sales_price as decimal(12,2))) agg4,
-        avg( cast(cs_net_profit as decimal(12,2))) agg5,
-        avg( cast(c_birth_year as decimal(12,2))) agg6,
-        avg( cast(cd1.cd_dep_count as decimal(12,2))) agg7
- from catalog_sales, customer_demographics cd1, 
-      customer_demographics cd2, customer, customer_address, date_dim, item
- where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk and
-       catalog_sales.cs_item_sk = item.i_item_sk and
-       catalog_sales.cs_bill_cdemo_sk = cd1.cd_demo_sk and
-       catalog_sales.cs_bill_customer_sk = customer.c_customer_sk and
-       cd1.cd_gender = 'M' and 
-       cd1.cd_education_status = 'College' and
-       customer.c_current_cdemo_sk = cd2.cd_demo_sk and
-       customer.c_current_addr_sk = customer_address.ca_address_sk and
-       c_birth_month in (9,5,12,4,1,10) and
-       d_year = 2001 and
-       cs_sold_date between '2001-01-01' and '2001-12-31' and
-       ca_state in ('ND','WI','AL'
-                   ,'NC','OK','MS','TN')
- group by i_item_id, ca_country, ca_state, ca_county with rollup
- order by ca_country,
-        ca_state, 
-        ca_county,
-	i_item_id
- limit 100;

+ 0 - 26
sample-queries/query19.sql

@@ -1,26 +0,0 @@
-
-select  i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact,
- 	sum(ss_ext_sales_price) ext_price
- from date_dim, store_sales, item,customer,customer_address,store
- where date_dim.d_date_sk = store_sales.ss_sold_date_sk
-   and store_sales.ss_item_sk = item.i_item_sk
-   and i_manager_id=7
-   and d_moy=11
-   and d_year=1999
-   and ss_sold_date between '1999-11-01' and '1999-11-31'
-   and store_sales.ss_customer_sk = customer.c_customer_sk 
-   and customer.c_current_addr_sk = customer_address.ca_address_sk
-   and substr(ca_zip,1,5) <> substr(s_zip,1,5) 
-   and store_sales.ss_store_sk = store.s_store_sk 
- group by i_brand
-      ,i_brand_id
-      ,i_manufact_id
-      ,i_manufact
- order by ext_price desc
-         ,i_brand
-         ,i_brand_id
-         ,i_manufact_id
-         ,i_manufact
-limit 100 ;
-
-

+ 0 - 27
sample-queries/query20.sql

@@ -1,27 +0,0 @@
-select  i_item_desc 
-       ,i_category 
-       ,i_class 
-       ,i_current_price
-       ,i_item_id
-       ,sum(cs_ext_sales_price) as itemrevenue 
-       ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
-           (partition by i_class) as revenueratio
- from	catalog_sales
-     ,item 
-     ,date_dim
- where catalog_sales.cs_item_sk = item.i_item_sk 
-   and i_category in ('Jewelry', 'Sports', 'Books')
-   and catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
- and d_date between '2001-01-12' and '2001-02-11'
- and cs_sold_date between '2001-01-12' and '2001-02-11'
- group by i_item_id
-         ,i_item_desc 
-         ,i_category
-         ,i_class
-         ,i_current_price
- order by i_category
-         ,i_class
-         ,i_item_id
-         ,i_item_desc
-         ,revenueratio
-limit 100;

+ 0 - 27
sample-queries/query21.sql

@@ -1,27 +0,0 @@
-select  *
- from(select w_warehouse_name
-            ,i_item_id
-            ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date))
-	                then inv_quantity_on_hand 
-                      else 0 end) as inv_before
-            ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date))
-                      then inv_quantity_on_hand 
-                      else 0 end) as inv_after
-   from inventory
-       ,warehouse
-       ,item
-       ,date_dim
-   where i_current_price between 0.99 and 1.49
-     and item.i_item_sk          = inventory.inv_item_sk
-     and inventory.inv_warehouse_sk   = warehouse.w_warehouse_sk
-     and inventory.inv_date_sk    = date_dim.d_date_sk
-     and d_date between '1998-03-09' and '1998-05-07'
-     and inv_date between '1998-03-09' and '1998-05-07'
-   group by w_warehouse_name, i_item_id) x
- where (case when inv_before > 0 
-             then inv_after / inv_before 
-             else null
-             end) between 2.0/3.0 and 3.0/2.0
- order by w_warehouse_name
-         ,i_item_id
- limit 100;

+ 0 - 20
sample-queries/query22.sql

@@ -1,20 +0,0 @@
-select  i_product_name
-             ,i_brand
-             ,i_class
-             ,i_category
-             ,avg(inv_quantity_on_hand) qoh
-       from inventory
-           ,date_dim
-           ,item
-           ,warehouse
-       where inventory.inv_date_sk=date_dim.d_date_sk
-              and inventory.inv_item_sk=item.i_item_sk
-              and inventory.inv_warehouse_sk = warehouse.w_warehouse_sk
-              and date_dim.d_month_seq between 1193 and 1193 + 11
-              and inv_date between '1999-06-01' and '2000-05-31'
-       group by i_product_name
-                       ,i_brand
-                       ,i_class
-                       ,i_category with rollup
-order by qoh, i_product_name, i_brand, i_class, i_category
-limit 100;

+ 0 - 19
sample-queries/query26.sql

@@ -1,19 +0,0 @@
-select  i_item_id, 
-        avg(cs_quantity) agg1,
-        avg(cs_list_price) agg2,
-        avg(cs_coupon_amt) agg3,
-        avg(cs_sales_price) agg4 
- from catalog_sales, customer_demographics, date_dim, item, promotion
- where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk and
-       catalog_sales.cs_item_sk = item.i_item_sk and
-       catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk and
-       catalog_sales.cs_promo_sk = promotion.p_promo_sk and
-       cd_gender = 'F' and 
-       cd_marital_status = 'W' and
-       cd_education_status = 'Primary' and
-       (p_channel_email = 'N' or p_channel_event = 'N') and
-       d_year = 1998
-       and cs_sold_date between '1998-01-01' and '1998-12-31'
- group by i_item_id
- order by i_item_id
- limit 100;

+ 0 - 23
sample-queries/query27.sql

@@ -1,23 +0,0 @@
-select  i_item_id,
-        s_state,
-        avg(ss_quantity) agg1,
-        avg(ss_list_price) agg2,
-        avg(ss_coupon_amt) agg3,
-        avg(ss_sales_price) agg4
- from store_sales, customer_demographics, date_dim, store, item
- where store_sales.ss_sold_date_sk = date_dim.d_date_sk and
-       store_sales.ss_item_sk = item.i_item_sk and
-       store_sales.ss_store_sk = store.s_store_sk and
-       store_sales.ss_cdemo_sk = customer_demographics.cd_demo_sk and
-       customer_demographics.cd_gender = 'F' and
-       customer_demographics.cd_marital_status = 'D' and
-       customer_demographics.cd_education_status = 'Unknown' and
-       date_dim.d_year = 1998 and
-       ss_sold_date between '1998-01-01' and '1998-12-31' and
-       store.s_state in ('KS','AL', 'MN', 'AL', 'SC', 'VT')
- group by i_item_id, s_state
- order by i_item_id
-         ,s_state
- limit 100;
-
-

+ 0 - 50
sample-queries/query28.sql

@@ -1,50 +0,0 @@
-select  *
-from (select avg(ss_list_price) B1_LP
-            ,count(ss_list_price) B1_CNT
-            ,count(distinct ss_list_price) B1_CNTD
-      from store_sales
-      where ss_quantity between 0 and 5
-        and (ss_list_price between 11 and 11+10 
-             or ss_coupon_amt between 460 and 460+1000
-             or ss_wholesale_cost between 14 and 14+20)) B1,
-     (select avg(ss_list_price) B2_LP
-            ,count(ss_list_price) B2_CNT
-            ,count(distinct ss_list_price) B2_CNTD
-      from store_sales
-      where ss_quantity between 6 and 10
-        and (ss_list_price between 91 and 91+10
-          or ss_coupon_amt between 1430 and 1430+1000
-          or ss_wholesale_cost between 32 and 32+20)) B2,
-     (select avg(ss_list_price) B3_LP
-            ,count(ss_list_price) B3_CNT
-            ,count(distinct ss_list_price) B3_CNTD
-      from store_sales
-      where ss_quantity between 11 and 15
-        and (ss_list_price between 66 and 66+10
-          or ss_coupon_amt between 920 and 920+1000
-          or ss_wholesale_cost between 4 and 4+20)) B3,
-     (select avg(ss_list_price) B4_LP
-            ,count(ss_list_price) B4_CNT
-            ,count(distinct ss_list_price) B4_CNTD
-      from store_sales
-      where ss_quantity between 16 and 20
-        and (ss_list_price between 142 and 142+10
-          or ss_coupon_amt between 3054 and 3054+1000
-          or ss_wholesale_cost between 80 and 80+20)) B4,
-     (select avg(ss_list_price) B5_LP
-            ,count(ss_list_price) B5_CNT
-            ,count(distinct ss_list_price) B5_CNTD
-      from store_sales
-      where ss_quantity between 21 and 25
-        and (ss_list_price between 135 and 135+10
-          or ss_coupon_amt between 14180 and 14180+1000
-          or ss_wholesale_cost between 38 and 38+20)) B5,
-     (select avg(ss_list_price) B6_LP
-            ,count(ss_list_price) B6_CNT
-            ,count(distinct ss_list_price) B6_CNTD
-      from store_sales
-      where ss_quantity between 26 and 30
-        and (ss_list_price between 28 and 28+10
-          or ss_coupon_amt between 2513 and 2513+1000
-          or ss_wholesale_cost between 42 and 42+20)) B6
-limit 100;

+ 0 - 25
sample-queries/query3.sql

@@ -1,25 +0,0 @@
-select  dt.d_year 
-       ,item.i_brand_id brand_id 
-       ,item.i_brand brand
-       ,sum(ss_ext_sales_price) sum_agg
- from  date_dim dt 
-      ,store_sales
-      ,item
- where dt.d_date_sk = store_sales.ss_sold_date_sk
-   and store_sales.ss_item_sk = item.i_item_sk
-   and item.i_manufact_id = 436
-   and dt.d_moy=12
-   and (
-	( ss_sold_date between '1998-12-01' and '1998-12-31' ) or
-	( ss_sold_date between '1999-12-01' and '1999-12-31' ) or
-	( ss_sold_date between '2000-12-01' and '2000-12-31' ) or
-	( ss_sold_date between '2001-12-01' and '2001-12-31' ) or
-	( ss_sold_date between '2002-12-01' and '2002-12-31' )
-   )
- group by dt.d_year
-      ,item.i_brand
-      ,item.i_brand_id
- order by dt.d_year
-         ,sum_agg desc
-         ,brand_id
- limit 100;

+ 0 - 20
sample-queries/query32.sql

@@ -1,20 +0,0 @@
-SELECT sum(cs1.cs_ext_discount_amt) as excess_discount_amount
-FROM (SELECT cs.cs_item_sk as cs_item_sk,
-                             cs.cs_ext_discount_amt as cs_ext_discount_amt
-             FROM catalog_sales cs
-             JOIN date_dim d ON (d.d_date_sk = cs.cs_sold_date_sk)
-             WHERE d.d_date between '2000-01-27' and '2000-04-27'
-		   and cs_sold_date between '2000-01-27' and '2000-04-27') cs1
-JOIN item i ON (i.i_item_sk = cs1.cs_item_sk)
-JOIN (SELECT cs2.cs_item_sk as cs_item_sk,
-                          1.3 * avg(cs_ext_discount_amt) as avg_cs_ext_discount_amt
-           FROM (SELECT cs.cs_item_sk as cs_item_sk,
-                                        cs.cs_ext_discount_amt as cs_ext_discount_amt
-                        FROM catalog_sales cs
-                        JOIN date_dim d ON (d.d_date_sk = cs.cs_sold_date_sk)
-                        WHERE d.d_date between '2000-01-27' and '2000-04-27'
-		   		and cs_sold_date between '2000-01-27' and '2000-04-27') cs2
-                        GROUP BY cs2.cs_item_sk) tmp1
-ON (i.i_item_sk = tmp1.cs_item_sk)
-WHERE i.i_manufact_id = 436 and
-               cs1.cs_ext_discount_amt > tmp1.avg_cs_ext_discount_amt;

+ 0 - 74
sample-queries/query34.sql

@@ -1,74 +0,0 @@
-select c_last_name
-       ,c_first_name
-       ,c_salutation
-       ,c_preferred_cust_flag
-       ,ss_ticket_number
-       ,cnt from
-   (select ss_ticket_number
-          ,ss_customer_sk
-          ,count(*) cnt
-    from store_sales,date_dim,store,household_demographics
-    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
-    and store_sales.ss_store_sk = store.s_store_sk  
-    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-    and (date_dim.d_dom between 1 and 3 or date_dim.d_dom between 25 and 28)
-    and (household_demographics.hd_buy_potential = '1001-5000' or
-         household_demographics.hd_buy_potential = '5001-10000')
-    and household_demographics.hd_vehicle_count > 0
-    and (case when household_demographics.hd_vehicle_count > 0 
-	then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count 
-	else null 
-	end)  > 1.2
-    and date_dim.d_year in (1998,1998+1,1998+2)
-    and (
-	ss_sold_date in (
-        '1998-01-01', '1998-01-02', '1998-01-03', '1998-01-25', '1998-01-26', '1998-01-27', 
-        '1998-01-28', '1998-02-01', '1998-02-02', '1998-02-03', '1998-02-25', '1998-02-26', 
-        '1998-02-27', '1998-02-28', '1998-03-01', '1998-03-02', '1998-03-03', '1998-03-25', 
-        '1998-03-26', '1998-03-27', '1998-03-28', '1998-04-01', '1998-04-02', '1998-04-03', 
-        '1998-04-25', '1998-04-26', '1998-04-27', '1998-04-28', '1998-05-01', '1998-05-02', 
-        '1998-05-03', '1998-05-25', '1998-05-26', '1998-05-27', '1998-05-28', '1998-06-01', 
-        '1998-06-02', '1998-06-03', '1998-06-25', '1998-06-26', '1998-06-27', '1998-06-28', 
-        '1998-07-01', '1998-07-02', '1998-07-03', '1998-07-25', '1998-07-26', '1998-07-27', 
-        '1998-07-28', '1998-08-01', '1998-08-02', '1998-08-03', '1998-08-25', '1998-08-26', 
-        '1998-08-27', '1998-08-28', '1998-09-01', '1998-09-02', '1998-09-03', '1998-09-25', 
-        '1998-09-26', '1998-09-27', '1998-09-28', '1998-10-01', '1998-10-02', '1998-10-03', 
-        '1998-10-25', '1998-10-26', '1998-10-27', '1998-10-28', '1998-11-01', '1998-11-02', 
-        '1998-11-03', '1998-11-25', '1998-11-26', '1998-11-27', '1998-11-28', '1998-12-01', 
-        '1998-12-02', '1998-12-03', '1998-12-25', '1998-12-26', '1998-12-27', '1998-12-28', 
-        '1999-01-01', '1999-01-02', '1999-01-03', '1999-01-25', '1999-01-26', '1999-01-27', 
-        '1999-01-28', '1999-02-01', '1999-02-02', '1999-02-03', '1999-02-25', '1999-02-26', 
-        '1999-02-27', '1999-02-28', '1999-03-01', '1999-03-02', '1999-03-03', '1999-03-25', 
-        '1999-03-26', '1999-03-27', '1999-03-28', '1999-04-01', '1999-04-02', '1999-04-03', 
-        '1999-04-25', '1999-04-26', '1999-04-27', '1999-04-28', '1999-05-01', '1999-05-02', 
-        '1999-05-03', '1999-05-25', '1999-05-26', '1999-05-27', '1999-05-28', '1999-06-01', 
-        '1999-06-02', '1999-06-03', '1999-06-25', '1999-06-26', '1999-06-27', '1999-06-28', 
-        '1999-07-01', '1999-07-02', '1999-07-03', '1999-07-25', '1999-07-26', '1999-07-27', 
-        '1999-07-28', '1999-08-01', '1999-08-02', '1999-08-03', '1999-08-25', '1999-08-26', 
-        '1999-08-27', '1999-08-28', '1999-09-01', '1999-09-02', '1999-09-03', '1999-09-25', 
-        '1999-09-26', '1999-09-27', '1999-09-28', '1999-10-01', '1999-10-02', '1999-10-03', 
-        '1999-10-25', '1999-10-26', '1999-10-27', '1999-10-28', '1999-11-01', '1999-11-02', 
-        '1999-11-03', '1999-11-25', '1999-11-26', '1999-11-27', '1999-11-28', '1999-12-01', 
-        '1999-12-02', '1999-12-03', '1999-12-25', '1999-12-26', '1999-12-27', '1999-12-28', 
-        '2000-01-01', '2000-01-02', '2000-01-03', '2000-01-25', '2000-01-26', '2000-01-27', 
-        '2000-01-28', '2000-02-01', '2000-02-02', '2000-02-03', '2000-02-25', '2000-02-26', 
-        '2000-02-27', '2000-02-28', '2000-03-01', '2000-03-02', '2000-03-03', '2000-03-25', 
-        '2000-03-26', '2000-03-27', '2000-03-28', '2000-04-01', '2000-04-02', '2000-04-03', 
-        '2000-04-25', '2000-04-26', '2000-04-27', '2000-04-28', '2000-05-01', '2000-05-02', 
-        '2000-05-03', '2000-05-25', '2000-05-26', '2000-05-27', '2000-05-28', '2000-06-01', 
-        '2000-06-02', '2000-06-03', '2000-06-25', '2000-06-26', '2000-06-27', '2000-06-28', 
-        '2000-07-01', '2000-07-02', '2000-07-03', '2000-07-25', '2000-07-26', '2000-07-27', 
-        '2000-07-28', '2000-08-01', '2000-08-02', '2000-08-03', '2000-08-25', '2000-08-26', 
-        '2000-08-27', '2000-08-28', '2000-09-01', '2000-09-02', '2000-09-03', '2000-09-25', 
-        '2000-09-26', '2000-09-27', '2000-09-28', '2000-10-01', '2000-10-02', '2000-10-03', 
-        '2000-10-25', '2000-10-26', '2000-10-27', '2000-10-28', '2000-11-01', '2000-11-02', 
-        '2000-11-03', '2000-11-25', '2000-11-26', '2000-11-27', '2000-11-28', '2000-12-01', 
-        '2000-12-02', '2000-12-03', '2000-12-25', '2000-12-26', '2000-12-27', '2000-12-28'
-	)
-    )
-    and store.s_county in ('Kittitas County','Adams County','Richland County','Furnas County',
-                           'Orange County','Appanoose County','Franklin Parish','Tehama County')
-    group by ss_ticket_number,ss_customer_sk) dn,customer
-    where dn.ss_customer_sk = customer.c_customer_sk
-      and cnt between 15 and 20
-    order by c_last_name,c_first_name,c_salutation,c_preferred_cust_flag desc;

+ 0 - 38
sample-queries/query39.sql

@@ -1,38 +0,0 @@
-select inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean, inv1.cov
-        ,inv2.w_warehouse_sk,inv2.i_item_sk,inv2.d_moy,inv2.mean, inv2.cov
-from
-(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
-       ,stdev,mean, case mean when cast (0 as double) then null else stdev/mean end cov
- from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
-            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
-      from inventory
-          JOIN item ON inventory.inv_item_sk = item.i_item_sk
-          JOIN warehouse ON inventory.inv_warehouse_sk = warehouse.w_warehouse_sk
-          JOIN date_dim ON inventory.inv_date_sk = date_dim.d_date_sk
-      where 
-         d_year =2000
-	 and inv_date between '2000-01-01' and '2000-12-31'
-      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
- where case mean when cast (0 as double) then cast (0 as double) else stdev/mean end > 1) inv1
-JOIN
-(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
-       ,stdev,mean, case mean when cast (0 as double) then null else stdev/mean end cov
- from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy
-            ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean
-      from inventory
-          JOIN item ON inventory.inv_item_sk = item.i_item_sk
-          JOIN warehouse ON inventory.inv_warehouse_sk = warehouse.w_warehouse_sk
-          JOIN date_dim ON inventory.inv_date_sk = date_dim.d_date_sk
-      where 
-         d_year =2000
-	 and inv_date between '2000-01-01' and '2000-12-31'
-      group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo
- where case mean when cast (0 as double) then cast (0 as double) else stdev/mean end > 1) inv2
-ON
- inv1.i_item_sk = inv2.i_item_sk
- and inv1.w_warehouse_sk =  inv2.w_warehouse_sk
-where
-      inv1.d_moy=1
-  and inv2.d_moy=1+1
-order by inv1.w_warehouse_sk,inv1.i_item_sk,inv1.d_moy,inv1.mean,inv1.cov
-        ,inv2.d_moy,inv2.mean, inv2.cov;

+ 0 - 27
sample-queries/query40.sql

@@ -1,27 +0,0 @@
-select  
-   w_state
-  ,i_item_id
-  ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date)) 
- 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_before
-  ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date)) 
- 		then cs_sales_price - coalesce(cr_refunded_cash,0) else 0 end) as sales_after
- from
-   catalog_sales left outer join catalog_returns on
-       (catalog_sales.cs_order_number = catalog_returns.cr_order_number 
-        and catalog_sales.cs_item_sk = catalog_returns.cr_item_sk)
-  ,warehouse 
-  ,item
-  ,date_dim
- where
-     i_current_price between 0.99 and 1.49
- and item.i_item_sk          = catalog_sales.cs_item_sk
- and catalog_sales.cs_warehouse_sk    = warehouse.w_warehouse_sk 
- and catalog_sales.cs_sold_date_sk    = date_dim.d_date_sk
- and date_dim.d_date between '1998-03-09' and '1998-05-08'
- and cs_sold_date between '1998-03-09' and '1998-05-08'
- group by
-    w_state,i_item_id
- order by w_state,i_item_id
-limit 100;
-
-

+ 0 - 22
sample-queries/query42.sql

@@ -1,22 +0,0 @@
-select  dt.d_year
- 	,item.i_category_id
- 	,item.i_category
- 	,sum(ss_ext_sales_price) as s
- from 	date_dim dt
- 	,store_sales
- 	,item
- where dt.d_date_sk = store_sales.ss_sold_date_sk
- 	and store_sales.ss_item_sk = item.i_item_sk
- 	and item.i_manager_id = 1  	
- 	and dt.d_moy=12
- 	and dt.d_year=1998
-        and ss_sold_date between '1998-12-01' and '1998-12-31'
- group by 	dt.d_year
- 		,item.i_category_id
- 		,item.i_category
- order by       s desc,dt.d_year
- 		,item.i_category_id
- 		,item.i_category
-limit 100 ;
-
-

+ 0 - 20
sample-queries/query43.sql

@@ -1,20 +0,0 @@
-
-select  s_store_name, s_store_id,
-        sum(case when (d_day_name='Sunday') then ss_sales_price else null end) sun_sales,
-        sum(case when (d_day_name='Monday') then ss_sales_price else null end) mon_sales,
-        sum(case when (d_day_name='Tuesday') then ss_sales_price else  null end) tue_sales,
-        sum(case when (d_day_name='Wednesday') then ss_sales_price else null end) wed_sales,
-        sum(case when (d_day_name='Thursday') then ss_sales_price else null end) thu_sales,
-        sum(case when (d_day_name='Friday') then ss_sales_price else null end) fri_sales,
-        sum(case when (d_day_name='Saturday') then ss_sales_price else null end) sat_sales
- from date_dim, store_sales, store
- where date_dim.d_date_sk = store_sales.ss_sold_date_sk and
-       store.s_store_sk = store_sales.ss_store_sk and
-       s_gmt_offset = -6 and
-       d_year = 1998
-       and ss_sold_date between '1998-01-01' and '1998-12-31'
- group by s_store_name, s_store_id
- order by s_store_name, s_store_id,sun_sales,mon_sales,tue_sales,wed_sales,thu_sales,fri_sales,sat_sales
- limit 100;
-
-

+ 0 - 18
sample-queries/query45.sql

@@ -1,18 +0,0 @@
-select  ca_zip, ca_county, sum(ws_sales_price)
- from
-    web_sales
-    JOIN customer ON web_sales.ws_bill_customer_sk = customer.c_customer_sk
-    JOIN customer_address ON customer.c_current_addr_sk = customer_address.ca_address_sk 
-    JOIN date_dim ON web_sales.ws_sold_date_sk = date_dim.d_date_sk
-    JOIN item ON web_sales.ws_item_sk = item.i_item_sk 
- where
-        ( item.i_item_id in (select i_item_id
-                             from item i2
-                             where i2.i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
-                             )
-            )
-        and d_qoy = 2 and d_year = 2000
-	and ws_sold_date between '2000-04-01' and '2000-06-30'
- group by ca_zip, ca_county
- order by ca_zip, ca_county
- limit 100;

+ 0 - 90
sample-queries/query46.sql

@@ -1,90 +0,0 @@
-
-select  c_last_name
-       ,c_first_name
-       ,ca_city
-       ,bought_city
-       ,ss_ticket_number
-       ,amt,profit 
- from
-   (select ss_ticket_number
-          ,ss_customer_sk
-          ,ca_city bought_city
-          ,sum(ss_coupon_amt) amt
-          ,sum(ss_net_profit) profit
-    from store_sales,date_dim,store,household_demographics,customer_address 
-    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
-    and store_sales.ss_store_sk = store.s_store_sk  
-    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-    and store_sales.ss_addr_sk = customer_address.ca_address_sk
-    and (household_demographics.hd_dep_count = 4 or
-         household_demographics.hd_vehicle_count= 2)
-    and date_dim.d_dow in (6,0)
-    and date_dim.d_year in (1998,1998+1,1998+2) 
-    and ss_sold_date in (
-        '1998-01-04', '1998-01-05', '1998-01-11', '1998-01-12', '1998-01-18', '1998-01-19', 
-        '1998-01-25', '1998-01-26', '1998-02-01', '1998-02-02', '1998-02-08', '1998-02-09', 
-        '1998-02-15', '1998-02-16', '1998-02-22', '1998-02-23', '1998-03-01', '1998-03-02', 
-        '1998-03-08', '1998-03-09', '1998-03-15', '1998-03-16', '1998-03-22', '1998-03-23', 
-        '1998-03-29', '1998-03-30', '1998-04-05', '1998-04-06', '1998-04-12', '1998-04-13', 
-        '1998-04-19', '1998-04-20', '1998-04-26', '1998-04-27', '1998-05-03', '1998-05-04', 
-        '1998-05-10', '1998-05-11', '1998-05-17', '1998-05-18', '1998-05-24', '1998-05-25', 
-        '1998-05-31', '1998-06-01', '1998-06-07', '1998-06-08', '1998-06-14', '1998-06-15', 
-        '1998-06-21', '1998-06-22', '1998-06-28', '1998-06-29', '1998-07-05', '1998-07-06', 
-        '1998-07-12', '1998-07-13', '1998-07-19', '1998-07-20', '1998-07-26', '1998-07-27', 
-        '1998-08-02', '1998-08-03', '1998-08-09', '1998-08-10', '1998-08-16', '1998-08-17', 
-        '1998-08-23', '1998-08-24', '1998-08-30', '1998-08-31', '1998-09-06', '1998-09-07', 
-        '1998-09-13', '1998-09-14', '1998-09-20', '1998-09-21', '1998-09-27', '1998-09-28', 
-        '1998-10-04', '1998-10-05', '1998-10-11', '1998-10-12', '1998-10-18', '1998-10-19', 
-        '1998-10-25', '1998-10-26', '1998-11-01', '1998-11-02', '1998-11-08', '1998-11-09', 
-        '1998-11-15', '1998-11-16', '1998-11-22', '1998-11-23', '1998-11-29', '1998-11-30', 
-        '1998-12-06', '1998-12-07', '1998-12-13', '1998-12-14', '1998-12-20', '1998-12-21', 
-        '1998-12-27', '1998-12-28', '1999-01-03', '1999-01-04', '1999-01-10', '1999-01-11', 
-        '1999-01-17', '1999-01-18', '1999-01-24', '1999-01-25', '1999-01-31', '1999-02-01', 
-        '1999-02-07', '1999-02-08', '1999-02-14', '1999-02-15', '1999-02-21', '1999-02-22', 
-        '1999-02-28', '1999-03-01', '1999-03-07', '1999-03-08', '1999-03-14', '1999-03-15', 
-        '1999-03-21', '1999-03-22', '1999-03-28', '1999-03-29', '1999-04-04', '1999-04-05', 
-        '1999-04-11', '1999-04-12', '1999-04-18', '1999-04-19', '1999-04-25', '1999-04-26', 
-        '1999-05-02', '1999-05-03', '1999-05-09', '1999-05-10', '1999-05-16', '1999-05-17', 
-        '1999-05-23', '1999-05-24', '1999-05-30', '1999-05-31', '1999-06-06', '1999-06-07', 
-        '1999-06-13', '1999-06-14', '1999-06-20', '1999-06-21', '1999-06-27', '1999-06-28', 
-        '1999-07-04', '1999-07-05', '1999-07-11', '1999-07-12', '1999-07-18', '1999-07-19', 
-        '1999-07-25', '1999-07-26', '1999-08-01', '1999-08-02', '1999-08-08', '1999-08-09', 
-        '1999-08-15', '1999-08-16', '1999-08-22', '1999-08-23', '1999-08-29', '1999-08-30', 
-        '1999-09-05', '1999-09-06', '1999-09-12', '1999-09-13', '1999-09-19', '1999-09-20', 
-        '1999-09-26', '1999-09-27', '1999-10-03', '1999-10-04', '1999-10-10', '1999-10-11', 
-        '1999-10-17', '1999-10-18', '1999-10-24', '1999-10-25', '1999-10-31', '1999-11-01', 
-        '1999-11-07', '1999-11-08', '1999-11-14', '1999-11-15', '1999-11-21', '1999-11-22', 
-        '1999-11-28', '1999-11-29', '1999-12-05', '1999-12-06', '1999-12-12', '1999-12-13', 
-        '1999-12-19', '1999-12-20', '1999-12-26', '1999-12-27', '2000-01-02', '2000-01-03', 
-        '2000-01-09', '2000-01-10', '2000-01-16', '2000-01-17', '2000-01-23', '2000-01-24', 
-        '2000-01-30', '2000-01-31', '2000-02-06', '2000-02-07', '2000-02-13', '2000-02-14', 
-        '2000-02-20', '2000-02-21', '2000-02-27', '2000-02-28', '2000-03-05', '2000-03-06', 
-        '2000-03-12', '2000-03-13', '2000-03-19', '2000-03-20', '2000-03-26', '2000-03-27', 
-        '2000-04-02', '2000-04-03', '2000-04-09', '2000-04-10', '2000-04-16', '2000-04-17', 
-        '2000-04-23', '2000-04-24', '2000-04-30', '2000-05-01', '2000-05-07', '2000-05-08', 
-        '2000-05-14', '2000-05-15', '2000-05-21', '2000-05-22', '2000-05-28', '2000-05-29', 
-        '2000-06-04', '2000-06-05', '2000-06-11', '2000-06-12', '2000-06-18', '2000-06-19', 
-        '2000-06-25', '2000-06-26', '2000-07-02', '2000-07-03', '2000-07-09', '2000-07-10', 
-        '2000-07-16', '2000-07-17', '2000-07-23', '2000-07-24', '2000-07-30', '2000-07-31', 
-        '2000-08-06', '2000-08-07', '2000-08-13', '2000-08-14', '2000-08-20', '2000-08-21', 
-        '2000-08-27', '2000-08-28', '2000-09-03', '2000-09-04', '2000-09-10', '2000-09-11', 
-        '2000-09-17', '2000-09-18', '2000-09-24', '2000-09-25', '2000-10-01', '2000-10-02', 
-        '2000-10-08', '2000-10-09', '2000-10-15', '2000-10-16', '2000-10-22', '2000-10-23', 
-        '2000-10-29', '2000-10-30', '2000-11-05', '2000-11-06', '2000-11-12', '2000-11-13', 
-        '2000-11-19', '2000-11-20', '2000-11-26', '2000-11-27', '2000-12-03', '2000-12-04', 
-        '2000-12-10', '2000-12-11', '2000-12-17', '2000-12-18', '2000-12-24', '2000-12-25', 
-        '2000-12-31', '2001-01-01'
-    )
-    and store.s_city in ('Rosedale','Bethlehem','Clinton','Clifton','Springfield') 
-    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,customer,customer_address current_addr
-    where dn.ss_customer_sk = customer.c_customer_sk
-      and customer.c_current_addr_sk = current_addr.ca_address_sk
-      and current_addr.ca_city <> bought_city
-  order by c_last_name
-          ,c_first_name
-          ,ca_city
-          ,bought_city
-          ,ss_ticket_number
-  limit 100;
-
-

+ 0 - 68
sample-queries/query48.sql

@@ -1,68 +0,0 @@
-
-select sum (ss_quantity)
- from store_sales, store, customer_demographics, customer_address, date_dim
- where store.s_store_sk = store_sales.ss_store_sk
- and  store_sales.ss_sold_date_sk = date_dim.d_date_sk and d_year = 1998
- and ss_sold_date between '1998-01-01' and '1998-12-31'
- and  
- (
-  (
-   customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk
-   and 
-   cd_marital_status = 'M'
-   and 
-   cd_education_status = '4 yr Degree'
-   and 
-   ss_sales_price between 100.00 and 150.00  
-   )
- or
-  (
-  customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk
-   and 
-   cd_marital_status = 'M'
-   and 
-   cd_education_status = '4 yr Degree'
-   and 
-   ss_sales_price between 50.00 and 100.00   
-  )
- or 
- (
-  customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk
-  and 
-   cd_marital_status = 'M'
-   and 
-   cd_education_status = '4 yr Degree'
-   and 
-   ss_sales_price between 150.00 and 200.00  
- )
- )
- and
- (
-  (
-  store_sales.ss_addr_sk = customer_address.ca_address_sk
-  and
-  ca_country = 'United States'
-  and
-  ca_state in ('KY', 'GA', 'NM')
-  and ss_net_profit between 0 and 2000  
-  )
- or
-  (store_sales.ss_addr_sk = customer_address.ca_address_sk
-  and
-  ca_country = 'United States'
-  and
-  ca_state in ('MT', 'OR', 'IN')
-  and ss_net_profit between 150 and 3000 
-  )
- or
-  (store_sales.ss_addr_sk = customer_address.ca_address_sk
-  and
-  ca_country = 'United States'
-  and
-  ca_state in ('WI', 'MO', 'WV')
-  and ss_net_profit between 50 and 25000 
-  )
- )
-;
-
-

+ 0 - 130
sample-queries/query49.sql

@@ -1,130 +0,0 @@
-
-select  
- 'web' as channel
- ,web.item
- ,web.return_ratio
- ,web.return_rank
- ,web.currency_rank
- from (
- 	select 
- 	 item
- 	,return_ratio
- 	,currency_ratio
- 	,rank() over (order by return_ratio) as return_rank
- 	,rank() over (order by currency_ratio) as currency_rank
- 	from
- 	(	select ws.ws_item_sk as item
- 		,(cast(sum(coalesce(wr.wr_return_quantity,0)) as decimal(15,4))/
- 		cast(sum(coalesce(ws.ws_quantity,0)) as decimal(15,4) )) as return_ratio
- 		,(cast(sum(coalesce(wr.wr_return_amt,0)) as decimal(15,4))/
- 		cast(sum(coalesce(ws.ws_net_paid,0)) as decimal(15,4) )) as currency_ratio
- 		from 
- 		 web_sales ws left outer join web_returns wr 
- 			on (ws.ws_order_number = wr.wr_order_number and 
- 			ws.ws_item_sk = wr.wr_item_sk)
-                 ,date_dim
- 		where 
- 			wr.wr_return_amt > 10000 
- 			and ws.ws_net_profit > 1
-                         and ws.ws_net_paid > 0
-                         and ws.ws_quantity > 0
-                         and ws.ws_sold_date_sk = date_dim.d_date_sk
-                         and d_year = 2000
-                         and d_moy = 12
-			 and ws.ws_sold_date between '2000-12-01' and '2000-12-31'
- 		group by ws.ws_item_sk
- 	) in_web
- ) web
- where 
- (
- web.return_rank <= 10
- or
- web.currency_rank <= 10
- )
- union all
- select 
- 'catalog' as channel
- ,catalog.item
- ,catalog.return_ratio
- ,catalog.return_rank
- ,catalog.currency_rank
- from (
- 	select 
- 	 item
- 	,return_ratio
- 	,currency_ratio
- 	,rank() over (order by return_ratio) as return_rank
- 	,rank() over (order by currency_ratio) as currency_rank
- 	from
- 	(	select 
- 		cs.cs_item_sk as item
- 		,(cast(sum(coalesce(cr.cr_return_quantity,0)) as decimal(15,4))/
- 		cast(sum(coalesce(cs.cs_quantity,0)) as decimal(15,4) )) as return_ratio
- 		,(cast(sum(coalesce(cr.cr_return_amount,0)) as decimal(15,4))/
- 		cast(sum(coalesce(cs.cs_net_paid,0)) as decimal(15,4) )) as currency_ratio
- 		from 
- 		catalog_sales cs left outer join catalog_returns cr
- 			on (cs.cs_order_number = cr.cr_order_number and 
- 			cs.cs_item_sk = cr.cr_item_sk)
-                ,date_dim
- 		where 
- 			cr.cr_return_amount > 10000 
- 			and cs.cs_net_profit > 1
-                         and cs.cs_net_paid > 0
-                         and cs.cs_quantity > 0
-                         and cs_sold_date_sk = d_date_sk
-                         and d_year = 2000
-                         and d_moy = 12
-			 and cs_sold_date between '2000-12-01' and '2000-12-31'
-                 group by cs.cs_item_sk
- 	) in_cat
- ) catalog
- where 
- (
- catalog.return_rank <= 10
- or
- catalog.currency_rank <=10
- )
- union all
- select 
- 'store' as channel
- ,store.item
- ,store.return_ratio
- ,store.return_rank
- ,store.currency_rank
- from (
- 	select 
- 	 item
- 	,return_ratio
- 	,currency_ratio
- 	,rank() over (order by return_ratio) as return_rank
- 	,rank() over (order by currency_ratio) as currency_rank
- 	from
- 	(	select sts.ss_item_sk as item
- 		,(cast(sum(coalesce(sr.sr_return_quantity,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as decimal(15,4) )) as return_ratio
- 		,(cast(sum(coalesce(sr.sr_return_amt,0)) as decimal(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as decimal(15,4) )) as currency_ratio
- 		from 
- 		store_sales sts left outer join store_returns sr
- 			on (sts.ss_ticket_number = sr.sr_ticket_number and sts.ss_item_sk = sr.sr_item_sk)
-                ,date_dim
- 		where 
- 			sr.sr_return_amt > 10000 
- 			and sts.ss_net_profit > 1
-                         and sts.ss_net_paid > 0 
-                         and sts.ss_quantity > 0
-                         and ss_sold_date_sk = d_date_sk
-                         and d_year = 2000
-                         and d_moy = 12
-			 and ss_sold_date between '2000-12-01' and '2000-12-31'
- 		group by sts.ss_item_sk
- 	) in_store
- ) store
- where  (
- store.return_rank <= 10
- or 
- store.currency_rank <= 10
- )
- order by 1,4,5
- limit 100;
-
-

+ 0 - 60
sample-queries/query50.sql

@@ -1,60 +0,0 @@
-
-select  
-   s_store_name
-  ,s_company_id
-  ,s_street_number
-  ,s_street_name
-  ,s_street_type
-  ,s_suite_number
-  ,s_city
-  ,s_county
-  ,s_state
-  ,s_zip
-  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end)  as 30days 
-  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 30) and 
-                 (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end )  as 3160days 
-  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 60) and 
-                 (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end)  as 6190days 
-  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk > 90) and
-                 (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end)  as 91120days 
-  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk  > 120) then 1 else 0 end)  as 120days 
-from
-   store_sales
-  ,store_returns
-  ,store
-  ,date_dim d1
-  ,date_dim d2
-where
-    d2.d_year = 2000
-and d2.d_moy  = 9
-and sr_returned_date between '2000-09-01' and '2000-09-30'
-and store_sales.ss_ticket_number = store_returns.sr_ticket_number
-and store_sales.ss_item_sk = store_returns.sr_item_sk
-and store_sales.ss_sold_date_sk   = d1.d_date_sk
-and sr_returned_date_sk   = d2.d_date_sk
-and store_sales.ss_customer_sk = store_returns.sr_customer_sk
-and store_sales.ss_store_sk = store.s_store_sk
-group by
-   s_store_name
-  ,s_company_id
-  ,s_street_number
-  ,s_street_name
-  ,s_street_type
-  ,s_suite_number
-  ,s_city
-  ,s_county
-  ,s_state
-  ,s_zip
-order by s_store_name
-        ,s_company_id
-        ,s_street_number
-        ,s_street_name
-        ,s_street_type
-        ,s_suite_number
-        ,s_city
-        ,s_county
-        ,s_state
-        ,s_zip
-limit 100;
-
-

+ 0 - 23
sample-queries/query52.sql

@@ -1,23 +0,0 @@
-
-select  dt.d_year
- 	,item.i_brand_id brand_id
- 	,item.i_brand brand
- 	,sum(ss_ext_sales_price) ext_price
- from date_dim dt
-     ,store_sales
-     ,item
- where dt.d_date_sk = store_sales.ss_sold_date_sk
-    and store_sales.ss_item_sk = item.i_item_sk
-    and item.i_manager_id = 1
-    and dt.d_moy=12
-    and dt.d_year=1998
-    and ss_sold_date between '1998-12-01' and '1998-12-31'
- group by dt.d_year
- 	,item.i_brand
- 	,item.i_brand_id
- order by dt.d_year
- 	,ext_price desc
- 	,brand_id
-limit 100 ;
-
-

+ 0 - 15
sample-queries/query55.sql

@@ -1,15 +0,0 @@
-
-select  i_brand_id brand_id, i_brand brand,
- 	sum(ss_ext_sales_price) ext_price
- from date_dim, store_sales, item
- where date_dim.d_date_sk = store_sales.ss_sold_date_sk
- 	and store_sales.ss_item_sk = item.i_item_sk
- 	and i_manager_id=36
- 	and d_moy=12
- 	and d_year=2001
-        and ss_sold_date between '2001-12-01' and '2001-12-31'
- group by i_brand, i_brand_id
- order by ext_price desc, i_brand_id
-limit 100 ;
-
-

+ 0 - 50
sample-queries/query58.sql

@@ -1,50 +0,0 @@
-  select  ss_items.item_id
-       ,ss_item_rev
-       ,ss_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ss_dev
-       ,cs_item_rev
-       ,cs_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 cs_dev
-       ,ws_item_rev
-       ,ws_item_rev/(ss_item_rev+cs_item_rev+ws_item_rev)/3 * 100 ws_dev
-       ,(ss_item_rev+cs_item_rev+ws_item_rev)/3 average
-FROM
-( select i_item_id item_id ,sum(ss_ext_sales_price) as ss_item_rev 
- from store_sales
-     JOIN item ON store_sales.ss_item_sk = item.i_item_sk
-     JOIN date_dim ON store_sales.ss_sold_date_sk = date_dim.d_date_sk
-     JOIN (select d1.d_date
-                 from date_dim d1 JOIN date_dim d2 ON d1.d_week_seq = d2.d_week_seq
-                 where d2.d_date = '1998-08-04') sub ON date_dim.d_date = sub.d_date
-     where ss_sold_date between '1998-08-04' and '1998-08-10'
- group by i_item_id ) ss_items
-JOIN
-( select i_item_id item_id ,sum(cs_ext_sales_price) as cs_item_rev 
- from catalog_sales
-     JOIN item ON catalog_sales.cs_item_sk = item.i_item_sk
-     JOIN date_dim ON catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
-     JOIN (select d1.d_date
-                 from date_dim d1 JOIN date_dim d2 ON d1.d_week_seq = d2.d_week_seq
-                 where d2.d_date = '1998-08-04') sub ON date_dim.d_date = sub.d_date
-     where cs_sold_date between '1998-08-04' and '1998-08-10'
- group by i_item_id ) cs_items
-ON ss_items.item_id=cs_items.item_id
-JOIN
-( select i_item_id item_id ,sum(ws_ext_sales_price) as ws_item_rev 
- from web_sales
-     JOIN item ON web_sales.ws_item_sk = item.i_item_sk
-     JOIN date_dim ON web_sales.ws_sold_date_sk = date_dim.d_date_sk
-     JOIN (select d1.d_date
-                 from date_dim d1 JOIN date_dim d2 ON d1.d_week_seq = d2.d_week_seq
-                 where d2.d_date = '1998-08-04') sub ON date_dim.d_date = sub.d_date
-     where ws_sold_date between '1998-08-04' and '1998-08-10'
- group by i_item_id ) ws_items
-ON ss_items.item_id=ws_items.item_id 
- where
-       ss_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
-   and ss_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
-   and cs_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
-   and cs_item_rev between 0.9 * ws_item_rev and 1.1 * ws_item_rev
-   and ws_item_rev between 0.9 * ss_item_rev and 1.1 * ss_item_rev
-   and ws_item_rev between 0.9 * cs_item_rev and 1.1 * cs_item_rev
- order by item_id ,ss_item_rev
- limit 100;
-

+ 0 - 98
sample-queries/query64.sql

@@ -1,98 +0,0 @@
-select cs1.product_name ,cs1.store_name ,cs1.store_zip ,cs1.b_street_number ,cs1.b_streen_name ,cs1.b_city
-     ,cs1.b_zip ,cs1.c_street_number ,cs1.c_street_name ,cs1.c_city ,cs1.c_zip ,cs1.syear ,cs1.cnt
-     ,cs1.s1 ,cs1.s2 ,cs1.s3
-     ,cs2.s1 ,cs2.s2 ,cs2.s3 ,cs2.syear ,cs2.cnt
-from
-(select i_product_name as product_name ,i_item_sk as item_sk ,s_store_name as store_name
-     ,s_zip as store_zip ,ad1.ca_street_number as b_street_number ,ad1.ca_street_name as b_streen_name
-     ,ad1.ca_city as b_city ,ad1.ca_zip as b_zip ,ad2.ca_street_number as c_street_number
-     ,ad2.ca_street_name as c_street_name ,ad2.ca_city as c_city ,ad2.ca_zip as c_zip
-     ,d1.d_year as syear ,d2.d_year as fsyear ,d3.d_year as s2year ,count(*) as cnt
-     ,sum(ss_wholesale_cost) as s1 ,sum(ss_list_price) as s2 ,sum(ss_coupon_amt) as s3
-  FROM   store_sales
-        JOIN store_returns ON store_sales.ss_item_sk = store_returns.sr_item_sk and store_sales.ss_ticket_number = store_returns.sr_ticket_number
-        JOIN customer ON store_sales.ss_customer_sk = customer.c_customer_sk
-        JOIN date_dim d1 ON store_sales.ss_sold_date_sk = d1.d_date_sk
-        JOIN date_dim d2 ON customer.c_first_sales_date_sk = d2.d_date_sk 
-        JOIN date_dim d3 ON customer.c_first_shipto_date_sk = d3.d_date_sk
-        JOIN store ON store_sales.ss_store_sk = store.s_store_sk
-        JOIN customer_demographics cd1 ON store_sales.ss_cdemo_sk= cd1.cd_demo_sk
-        JOIN customer_demographics cd2 ON customer.c_current_cdemo_sk = cd2.cd_demo_sk
-        JOIN promotion ON store_sales.ss_promo_sk = promotion.p_promo_sk
-        JOIN household_demographics hd1 ON store_sales.ss_hdemo_sk = hd1.hd_demo_sk
-        JOIN household_demographics hd2 ON customer.c_current_hdemo_sk = hd2.hd_demo_sk
-        JOIN customer_address ad1 ON store_sales.ss_addr_sk = ad1.ca_address_sk
-        JOIN customer_address ad2 ON customer.c_current_addr_sk = ad2.ca_address_sk
-        JOIN income_band ib1 ON hd1.hd_income_band_sk = ib1.ib_income_band_sk
-        JOIN income_band ib2 ON hd2.hd_income_band_sk = ib2.ib_income_band_sk
-        JOIN item ON store_sales.ss_item_sk = item.i_item_sk
-        JOIN
- (select cs_item_sk
-        ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund
-  from catalog_sales JOIN catalog_returns
-  ON catalog_sales.cs_item_sk = catalog_returns.cr_item_sk
-    and catalog_sales.cs_order_number = catalog_returns.cr_order_number
-  group by cs_item_sk
-  having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)) cs_ui
-ON store_sales.ss_item_sk = cs_ui.cs_item_sk
-  WHERE  
-         cd1.cd_marital_status <> cd2.cd_marital_status and
-         i_color in ('maroon','burnished','dim','steel','navajo','chocolate') and
-         i_current_price between 35 and 35 + 10 and
-         i_current_price between 35 + 1 and 35 + 15
-	 and ss_sold_date between '2000-01-01' and '2000-12-31'
-group by i_product_name ,i_item_sk ,s_store_name ,s_zip ,ad1.ca_street_number
-       ,ad1.ca_street_name ,ad1.ca_city ,ad1.ca_zip ,ad2.ca_street_number
-       ,ad2.ca_street_name ,ad2.ca_city ,ad2.ca_zip ,d1.d_year ,d2.d_year ,d3.d_year
-) cs1
-JOIN
-(select i_product_name as product_name ,i_item_sk as item_sk ,s_store_name as store_name
-     ,s_zip as store_zip ,ad1.ca_street_number as b_street_number ,ad1.ca_street_name as b_streen_name
-     ,ad1.ca_city as b_city ,ad1.ca_zip as b_zip ,ad2.ca_street_number as c_street_number
-     ,ad2.ca_street_name as c_street_name ,ad2.ca_city as c_city ,ad2.ca_zip as c_zip
-     ,d1.d_year as syear ,d2.d_year as fsyear ,d3.d_year as s2year ,count(*) as cnt
-     ,sum(ss_wholesale_cost) as s1 ,sum(ss_list_price) as s2 ,sum(ss_coupon_amt) as s3
-  FROM   store_sales
-        JOIN store_returns ON store_sales.ss_item_sk = store_returns.sr_item_sk and store_sales.ss_ticket_number = store_returns.sr_ticket_number
-        JOIN customer ON store_sales.ss_customer_sk = customer.c_customer_sk
-        JOIN date_dim d1 ON store_sales.ss_sold_date_sk = d1.d_date_sk
-        JOIN date_dim d2 ON customer.c_first_sales_date_sk = d2.d_date_sk 
-        JOIN date_dim d3 ON customer.c_first_shipto_date_sk = d3.d_date_sk
-        JOIN store ON store_sales.ss_store_sk = store.s_store_sk
-        JOIN customer_demographics cd1 ON store_sales.ss_cdemo_sk= cd1.cd_demo_sk
-        JOIN customer_demographics cd2 ON customer.c_current_cdemo_sk = cd2.cd_demo_sk
-        JOIN promotion ON store_sales.ss_promo_sk = promotion.p_promo_sk
-        JOIN household_demographics hd1 ON store_sales.ss_hdemo_sk = hd1.hd_demo_sk
-        JOIN household_demographics hd2 ON customer.c_current_hdemo_sk = hd2.hd_demo_sk
-        JOIN customer_address ad1 ON store_sales.ss_addr_sk = ad1.ca_address_sk
-        JOIN customer_address ad2 ON customer.c_current_addr_sk = ad2.ca_address_sk
-        JOIN income_band ib1 ON hd1.hd_income_band_sk = ib1.ib_income_band_sk
-        JOIN income_band ib2 ON hd2.hd_income_band_sk = ib2.ib_income_band_sk
-        JOIN item ON store_sales.ss_item_sk = item.i_item_sk
-        JOIN
- (select cs_item_sk
-        ,sum(cs_ext_list_price) as sale,sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit) as refund
-  from catalog_sales JOIN catalog_returns
-  ON catalog_sales.cs_item_sk = catalog_returns.cr_item_sk
-    and catalog_sales.cs_order_number = catalog_returns.cr_order_number
-  group by cs_item_sk
-  having sum(cs_ext_list_price)>2*sum(cr_refunded_cash+cr_reversed_charge+cr_store_credit)) cs_ui
-ON store_sales.ss_item_sk = cs_ui.cs_item_sk
-  WHERE  
-         cd1.cd_marital_status <> cd2.cd_marital_status and
-         i_color in ('maroon','burnished','dim','steel','navajo','chocolate') and
-         i_current_price between 35 and 35 + 10 and
-         i_current_price between 35 + 1 and 35 + 15
-	 and ss_sold_date between '2001-01-01' and '2001-12-31'
-group by i_product_name ,i_item_sk ,s_store_name ,s_zip ,ad1.ca_street_number
-       ,ad1.ca_street_name ,ad1.ca_city ,ad1.ca_zip ,ad2.ca_street_number
-       ,ad2.ca_street_name ,ad2.ca_city ,ad2.ca_zip ,d1.d_year ,d2.d_year ,d3.d_year
-) cs2
-ON cs1.item_sk=cs2.item_sk
-where 
-     cs1.syear = 2000 and
-     cs2.syear = 2000 + 1 and
-     cs2.cnt <= cs1.cnt and
-     cs1.store_name = cs2.store_name and
-     cs1.store_zip = cs2.store_zip
-order by cs1.product_name ,cs1.store_name ,cs2.cnt;

+ 0 - 222
sample-queries/query66.sql

@@ -1,222 +0,0 @@
-
-select   
-         w_warehouse_name
- 	,w_warehouse_sq_ft
- 	,w_city
- 	,w_county
- 	,w_state
- 	,w_country
-        ,ship_carriers
-        ,year
- 	,sum(jan_sales) as jan_sales
- 	,sum(feb_sales) as feb_sales
- 	,sum(mar_sales) as mar_sales
- 	,sum(apr_sales) as apr_sales
- 	,sum(may_sales) as may_sales
- 	,sum(jun_sales) as jun_sales
- 	,sum(jul_sales) as jul_sales
- 	,sum(aug_sales) as aug_sales
- 	,sum(sep_sales) as sep_sales
- 	,sum(oct_sales) as oct_sales
- 	,sum(nov_sales) as nov_sales
- 	,sum(dec_sales) as dec_sales
- 	,sum(jan_sales/w_warehouse_sq_ft) as jan_sales_per_sq_foot
- 	,sum(feb_sales/w_warehouse_sq_ft) as feb_sales_per_sq_foot
- 	,sum(mar_sales/w_warehouse_sq_ft) as mar_sales_per_sq_foot
- 	,sum(apr_sales/w_warehouse_sq_ft) as apr_sales_per_sq_foot
- 	,sum(may_sales/w_warehouse_sq_ft) as may_sales_per_sq_foot
- 	,sum(jun_sales/w_warehouse_sq_ft) as jun_sales_per_sq_foot
- 	,sum(jul_sales/w_warehouse_sq_ft) as jul_sales_per_sq_foot
- 	,sum(aug_sales/w_warehouse_sq_ft) as aug_sales_per_sq_foot
- 	,sum(sep_sales/w_warehouse_sq_ft) as sep_sales_per_sq_foot
- 	,sum(oct_sales/w_warehouse_sq_ft) as oct_sales_per_sq_foot
- 	,sum(nov_sales/w_warehouse_sq_ft) as nov_sales_per_sq_foot
- 	,sum(dec_sales/w_warehouse_sq_ft) as dec_sales_per_sq_foot
- 	,sum(jan_net) as jan_net
- 	,sum(feb_net) as feb_net
- 	,sum(mar_net) as mar_net
- 	,sum(apr_net) as apr_net
- 	,sum(may_net) as may_net
- 	,sum(jun_net) as jun_net
- 	,sum(jul_net) as jul_net
- 	,sum(aug_net) as aug_net
- 	,sum(sep_net) as sep_net
- 	,sum(oct_net) as oct_net
- 	,sum(nov_net) as nov_net
- 	,sum(dec_net) as dec_net
- from (
-    select 
- 	w_warehouse_name
- 	,w_warehouse_sq_ft
- 	,w_city
- 	,w_county
- 	,w_state
- 	,w_country
- 	,concat('DIAMOND', ',', 'AIRBORNE') as ship_carriers
-        ,d_year as year
- 	,sum(case when d_moy = 1 
- 		then ws_sales_price* ws_quantity else 0 end) as jan_sales
- 	,sum(case when d_moy = 2 
- 		then ws_sales_price* ws_quantity else 0 end) as feb_sales
- 	,sum(case when d_moy = 3 
- 		then ws_sales_price* ws_quantity else 0 end) as mar_sales
- 	,sum(case when d_moy = 4 
- 		then ws_sales_price* ws_quantity else 0 end) as apr_sales
- 	,sum(case when d_moy = 5 
- 		then ws_sales_price* ws_quantity else 0 end) as may_sales
- 	,sum(case when d_moy = 6 
- 		then ws_sales_price* ws_quantity else 0 end) as jun_sales
- 	,sum(case when d_moy = 7 
- 		then ws_sales_price* ws_quantity else 0 end) as jul_sales
- 	,sum(case when d_moy = 8 
- 		then ws_sales_price* ws_quantity else 0 end) as aug_sales
- 	,sum(case when d_moy = 9 
- 		then ws_sales_price* ws_quantity else 0 end) as sep_sales
- 	,sum(case when d_moy = 10 
- 		then ws_sales_price* ws_quantity else 0 end) as oct_sales
- 	,sum(case when d_moy = 11
- 		then ws_sales_price* ws_quantity else 0 end) as nov_sales
- 	,sum(case when d_moy = 12
- 		then ws_sales_price* ws_quantity else 0 end) as dec_sales
- 	,sum(case when d_moy = 1 
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jan_net
- 	,sum(case when d_moy = 2
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as feb_net
- 	,sum(case when d_moy = 3 
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as mar_net
- 	,sum(case when d_moy = 4 
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as apr_net
- 	,sum(case when d_moy = 5 
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as may_net
- 	,sum(case when d_moy = 6 
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jun_net
- 	,sum(case when d_moy = 7 
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as jul_net
- 	,sum(case when d_moy = 8 
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as aug_net
- 	,sum(case when d_moy = 9 
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as sep_net
- 	,sum(case when d_moy = 10 
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as oct_net
- 	,sum(case when d_moy = 11
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as nov_net
- 	,sum(case when d_moy = 12
- 		then ws_net_paid_inc_tax * ws_quantity else 0 end) as dec_net
-     from
-          web_sales
-         ,warehouse
-         ,date_dim
-         ,time_dim
- 	  ,ship_mode
-     where
-            web_sales.ws_warehouse_sk =  warehouse.w_warehouse_sk
-        and web_sales.ws_sold_date_sk = date_dim.d_date_sk
-        and web_sales.ws_sold_time_sk = time_dim.t_time_sk
- 	and web_sales.ws_ship_mode_sk = ship_mode.sm_ship_mode_sk
-        and d_year = 2002
-	and ws_sold_date between '2002-01-01' and '2002-12-31'
- 	and t_time between 49530 and 49530+28800 
- 	and sm_carrier in ('DIAMOND','AIRBORNE')
-     group by 
-        w_warehouse_name
- 	,w_warehouse_sq_ft
- 	,w_city
- 	,w_county
- 	,w_state
- 	,w_country
-       ,d_year
- union all
-    select 
- 	w_warehouse_name
- 	,w_warehouse_sq_ft
- 	,w_city
- 	,w_county
- 	,w_state
- 	,w_country
-        ,concat('DIAMOND', ',', 'AIRBORNE') as ship_carriers
-       ,d_year as year
- 	,sum(case when d_moy = 1 
- 		then cs_ext_sales_price* cs_quantity else 0 end) as jan_sales
- 	,sum(case when d_moy = 2 
- 		then cs_ext_sales_price* cs_quantity else 0 end) as feb_sales
- 	,sum(case when d_moy = 3 
- 		then cs_ext_sales_price* cs_quantity else 0 end) as mar_sales
- 	,sum(case when d_moy = 4 
- 		then cs_ext_sales_price* cs_quantity else 0 end) as apr_sales
- 	,sum(case when d_moy = 5 
- 		then cs_ext_sales_price* cs_quantity else 0 end) as may_sales
- 	,sum(case when d_moy = 6 
- 		then cs_ext_sales_price* cs_quantity else 0 end) as jun_sales
- 	,sum(case when d_moy = 7 
- 		then cs_ext_sales_price* cs_quantity else 0 end) as jul_sales
- 	,sum(case when d_moy = 8 
- 		then cs_ext_sales_price* cs_quantity else 0 end) as aug_sales
- 	,sum(case when d_moy = 9 
- 		then cs_ext_sales_price* cs_quantity else 0 end) as sep_sales
- 	,sum(case when d_moy = 10 
- 		then cs_ext_sales_price* cs_quantity else 0 end) as oct_sales
- 	,sum(case when d_moy = 11
- 		then cs_ext_sales_price* cs_quantity else 0 end) as nov_sales
- 	,sum(case when d_moy = 12
- 		then cs_ext_sales_price* cs_quantity else 0 end) as dec_sales
- 	,sum(case when d_moy = 1 
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jan_net
- 	,sum(case when d_moy = 2 
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as feb_net
- 	,sum(case when d_moy = 3 
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as mar_net
- 	,sum(case when d_moy = 4 
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as apr_net
- 	,sum(case when d_moy = 5 
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as may_net
- 	,sum(case when d_moy = 6 
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jun_net
- 	,sum(case when d_moy = 7 
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as jul_net
- 	,sum(case when d_moy = 8 
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as aug_net
- 	,sum(case when d_moy = 9 
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as sep_net
- 	,sum(case when d_moy = 10 
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as oct_net
- 	,sum(case when d_moy = 11
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as nov_net
- 	,sum(case when d_moy = 12
- 		then cs_net_paid_inc_ship_tax * cs_quantity else 0 end) as dec_net
-     from
-          catalog_sales
-         ,warehouse
-         ,date_dim
-         ,time_dim
- 	 ,ship_mode
-     where
-            catalog_sales.cs_warehouse_sk =  warehouse.w_warehouse_sk
-        and catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
-        and catalog_sales.cs_sold_time_sk = time_dim.t_time_sk
- 	and catalog_sales.cs_ship_mode_sk = ship_mode.sm_ship_mode_sk
-        and d_year = 2002
-	and cs_sold_date between '2002-01-01' and '2002-12-31'
- 	and t_time between 49530 AND 49530+28800 
- 	and sm_carrier in ('DIAMOND','AIRBORNE')
-     group by 
-        w_warehouse_name
- 	,w_warehouse_sq_ft
- 	,w_city
- 	,w_county
- 	,w_state
- 	,w_country
-       ,d_year
- ) x
- group by 
-        w_warehouse_name
- 	,w_warehouse_sq_ft
- 	,w_city
- 	,w_county
- 	,w_state
- 	,w_country
- 	,ship_carriers
-       ,year
- order by w_warehouse_name
- limit 100;
-
-

+ 0 - 45
sample-queries/query67.sql

@@ -1,45 +0,0 @@
-
-select  *
-from (select i_category
-            ,i_class
-            ,i_brand
-            ,i_product_name
-            ,d_year
-            ,d_qoy
-            ,d_moy
-            ,s_store_id
-            ,sumsales
-            ,rank() over (partition by i_category order by sumsales desc) rk
-      from (select i_category
-                  ,i_class
-                  ,i_brand
-                  ,i_product_name
-                  ,d_year
-                  ,d_qoy
-                  ,d_moy
-                  ,s_store_id
-                  ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales
-            from store_sales
-                ,date_dim
-                ,store
-                ,item
-       where  store_sales.ss_sold_date_sk=date_dim.d_date_sk
-          and store_sales.ss_item_sk=item.i_item_sk
-          and store_sales.ss_store_sk = store.s_store_sk
-          and d_month_seq between 1193 and 1193+11
-          and ss_sold_date between '1999-06-01' and '2000-05-31'
-       group by i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id with rollup)dw1) dw2
-where rk <= 100
-order by i_category
-        ,i_class
-        ,i_brand
-        ,i_product_name
-        ,d_year
-        ,d_qoy
-        ,d_moy
-        ,s_store_id
-        ,sumsales
-        ,rk
-limit 100;
-
-

+ 0 - 56
sample-queries/query68.sql

@@ -1,56 +0,0 @@
-
-select  c_last_name
-       ,c_first_name
-       ,ca_city
-       ,bought_city
-       ,ss_ticket_number
-       ,extended_price
-       ,extended_tax
-       ,list_price
- from (select ss_ticket_number
-             ,ss_customer_sk
-             ,ca_city bought_city
-             ,sum(ss_ext_sales_price) extended_price 
-             ,sum(ss_ext_list_price) list_price
-             ,sum(ss_ext_tax) extended_tax 
-       from store_sales
-           ,date_dim
-           ,store
-           ,household_demographics
-           ,customer_address 
-       where store_sales.ss_sold_date_sk = date_dim.d_date_sk
-         and store_sales.ss_store_sk = store.s_store_sk  
-        and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-        and store_sales.ss_addr_sk = customer_address.ca_address_sk
-        and date_dim.d_dom between 1 and 2 
-        and (household_demographics.hd_dep_count = 4 or
-             household_demographics.hd_vehicle_count= 2)
-        and date_dim.d_year in (1998,1998+1,1998+2)
-        and ss_sold_date in (
-        '1998-01-01', '1998-01-02', '1998-02-01', '1998-02-02', '1998-03-01', '1998-03-02', 
-        '1998-04-01', '1998-04-02', '1998-05-01', '1998-05-02', '1998-06-01', '1998-06-02', 
-        '1998-07-01', '1998-07-02', '1998-08-01', '1998-08-02', '1998-09-01', '1998-09-02', 
-        '1998-10-01', '1998-10-02', '1998-11-01', '1998-11-02', '1998-12-01', '1998-12-02', 
-        '1999-01-01', '1999-01-02', '1999-02-01', '1999-02-02', '1999-03-01', '1999-03-02', 
-        '1999-04-01', '1999-04-02', '1999-05-01', '1999-05-02', '1999-06-01', '1999-06-02', 
-        '1999-07-01', '1999-07-02', '1999-08-01', '1999-08-02', '1999-09-01', '1999-09-02', 
-        '1999-10-01', '1999-10-02', '1999-11-01', '1999-11-02', '1999-12-01', '1999-12-02', 
-        '2000-01-01', '2000-01-02', '2000-02-01', '2000-02-02', '2000-03-01', '2000-03-02', 
-        '2000-04-01', '2000-04-02', '2000-05-01', '2000-05-02', '2000-06-01', '2000-06-02', 
-        '2000-07-01', '2000-07-02', '2000-08-01', '2000-08-02', '2000-09-01', '2000-09-02', 
-        '2000-10-01', '2000-10-02', '2000-11-01', '2000-11-02', '2000-12-01', '2000-12-02'
-	)
-        and store.s_city in ('Rosedale','Bethlehem')
-       group by ss_ticket_number
-               ,ss_customer_sk
-               ,ss_addr_sk,ca_city) dn
-      ,customer
-      ,customer_address current_addr
- where dn.ss_customer_sk = customer.c_customer_sk
-   and customer.c_current_addr_sk = current_addr.ca_address_sk
-   and current_addr.ca_city <> bought_city
- order by c_last_name
-         ,ss_ticket_number
- limit 100;
-
-

+ 0 - 22
sample-queries/query7.sql

@@ -1,22 +0,0 @@
-
-select  i_item_id, 
-        avg(ss_quantity) agg1,
-        avg(ss_list_price) agg2,
-        avg(ss_coupon_amt) agg3,
-        avg(ss_sales_price) agg4 
- from store_sales, customer_demographics, date_dim, item, promotion
- where store_sales.ss_sold_date_sk = date_dim.d_date_sk and
-       store_sales.ss_item_sk = item.i_item_sk and
-       store_sales.ss_cdemo_sk = customer_demographics.cd_demo_sk and
-       store_sales.ss_promo_sk = promotion.p_promo_sk and
-       cd_gender = 'F' and 
-       cd_marital_status = 'W' and
-       cd_education_status = 'Primary' and
-       (p_channel_email = 'N' or p_channel_event = 'N') and
-       d_year = 1998 
-       and ss_sold_date between '1998-01-01' and '1998-12-31'
- group by i_item_id
- order by i_item_id
- limit 100;
-
-

+ 0 - 31
sample-queries/query70.sql

@@ -1,31 +0,0 @@
-select  
-    sum(ss_net_profit) as total_sum
-   ,s_state
-   ,s_county
-   ,grouping__id as lochierarchy
-   , rank() over(partition by grouping__id, case when grouping__id == 2 then s_state end order by sum(ss_net_profit)) as rank_within_parent
-from
-    store_sales ss join date_dim d1 on d1.d_date_sk = ss.ss_sold_date_sk
-    join store s on s.s_store_sk  = ss.ss_store_sk
- where
-    d1.d_month_seq between 1193 and 1193+11
-    and ss_sold_date between '1999-06-01' and '2000-05-31'
- and s.s_state in
-             ( select s_state
-               from  (select s_state as s_state, sum(ss_net_profit),
-                             rank() over ( partition by s_state order by sum(ss_net_profit) desc) as ranking
-                      from   store_sales, store, date_dim
-                      where  d_month_seq between 1193 and 1193+11
-                            and date_dim.d_date_sk = store_sales.ss_sold_date_sk
-                            and store.s_store_sk  = store_sales.ss_store_sk
-                            and ss_sold_date between '1999-06-01' and '2000-05-31'
-                      group by s_state
-                     ) tmp1 
-               where ranking <= 5
-             )
- group by s_state,s_county with rollup
-order by
-   lochierarchy desc
-  ,case when lochierarchy = 0 then s_state end
-  ,rank_within_parent
- limit 100;

+ 0 - 41
sample-queries/query71.sql

@@ -1,41 +0,0 @@
-select i_brand_id brand_id, i_brand brand,t_hour,t_minute,
- 	sum(ext_price) ext_price
- from item JOIN (select ws_ext_sales_price as ext_price, 
-                        ws_sold_date_sk as sold_date_sk,
-                        ws_item_sk as sold_item_sk,
-                        ws_sold_time_sk as time_sk  
-                 from web_sales,date_dim
-                 where date_dim.d_date_sk = web_sales.ws_sold_date_sk
-                   and d_moy=12
-                   and d_year=2001
-		   and ws_sold_date between '2001-12-01' and '2001-12-31'
-                 union all
-                 select cs_ext_sales_price as ext_price,
-                        cs_sold_date_sk as sold_date_sk,
-                        cs_item_sk as sold_item_sk,
-                        cs_sold_time_sk as time_sk
-                 from catalog_sales,date_dim
-                 where date_dim.d_date_sk = catalog_sales.cs_sold_date_sk
-                   and d_moy=12
-                   and d_year=2001
-		   and cs_sold_date between '2001-12-01' and '2001-12-31'
-                 union all
-                 select ss_ext_sales_price as ext_price,
-                        ss_sold_date_sk as sold_date_sk,
-                        ss_item_sk as sold_item_sk,
-                        ss_sold_time_sk as time_sk
-                 from store_sales,date_dim
-                 where date_dim.d_date_sk = store_sales.ss_sold_date_sk
-                   and d_moy=12
-                   and d_year=2001
-		   and ss_sold_date between '2001-12-01' and '2001-12-31'
-                 ) tmp ON tmp.sold_item_sk = item.i_item_sk
- JOIN time_dim ON tmp.time_sk = time_dim.t_time_sk
- where
-       i_manager_id=1
-   and (t_meal_time = 'breakfast' or t_meal_time = 'dinner')
- group by i_brand, i_brand_id,t_hour,t_minute
- order by ext_price desc, i_brand_id
- ;
-
-

+ 0 - 33
sample-queries/query72.sql

@@ -1,33 +0,0 @@
-
-select  i_item_desc
-      ,w_warehouse_name
-      ,d1.d_week_seq
-      ,count(case when p_promo_sk is null then 1 else 0 end) no_promo
-      ,count(case when p_promo_sk is not null then 1 else 0 end) promo
-      ,count(*) total_cnt
-from catalog_sales
-join inventory on (catalog_sales.cs_item_sk = inventory.inv_item_sk)
-join warehouse on (warehouse.w_warehouse_sk=inventory.inv_warehouse_sk)
-join item on (item.i_item_sk = catalog_sales.cs_item_sk)
-join customer_demographics on (catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk)
-join household_demographics on (catalog_sales.cs_bill_hdemo_sk = household_demographics.hd_demo_sk)
-join date_dim d1 on (catalog_sales.cs_sold_date_sk = d1.d_date_sk)
-join date_dim d2 on (inventory.inv_date_sk = d2.d_date_sk)
-join date_dim d3 on (catalog_sales.cs_ship_date_sk = d3.d_date_sk)
-left outer join promotion on (catalog_sales.cs_promo_sk=promotion.p_promo_sk)
-left outer join catalog_returns on (catalog_returns.cr_item_sk = catalog_sales.cs_item_sk and catalog_returns.cr_order_number = catalog_sales.cs_order_number)
-where d1.d_week_seq = d2.d_week_seq
-  and inv_quantity_on_hand < cs_quantity 
-  and d3.d_date > d1.d_date + 5
-  and hd_buy_potential = '1001-5000'
-  and d1.d_year = 2001
-  and hd_buy_potential = '1001-5000'
-  and cd_marital_status = 'M'
-  and d1.d_year = 2001
-  and inv_date between '2001-01-01' and '2001-12-31'
-  and cs_sold_date between '2001-01-01' and '2002-12-31'
-group by i_item_desc,w_warehouse_name,d1.d_week_seq
-order by total_cnt desc, i_item_desc, w_warehouse_name, d_week_seq
-limit 100;
-
-

+ 0 - 42
sample-queries/query73.sql

@@ -1,42 +0,0 @@
-
-select c_last_name
-       ,c_first_name
-       ,c_salutation
-       ,c_preferred_cust_flag 
-       ,ss_ticket_number
-       ,cnt from
-   (select ss_ticket_number
-          ,ss_customer_sk
-          ,count(*) cnt
-    from store_sales,date_dim,store,household_demographics
-    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
-    and store_sales.ss_store_sk = store.s_store_sk  
-    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-    and date_dim.d_dom between 1 and 2 
-    and (household_demographics.hd_buy_potential = '1001-5000' or
-         household_demographics.hd_buy_potential = '5001-10000')
-    and household_demographics.hd_vehicle_count > 0
-    and case when household_demographics.hd_vehicle_count > 0 then 
-             household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null end > 1
-    and date_dim.d_year in (1998,1998+1,1998+2)
-    and ss_sold_date in (
-        '1998-01-01', '1998-01-02', '1998-02-01', '1998-02-02', '1998-03-01', '1998-03-02', 
-        '1998-04-01', '1998-04-02', '1998-05-01', '1998-05-02', '1998-06-01', '1998-06-02', 
-        '1998-07-01', '1998-07-02', '1998-08-01', '1998-08-02', '1998-09-01', '1998-09-02', 
-        '1998-10-01', '1998-10-02', '1998-11-01', '1998-11-02', '1998-12-01', '1998-12-02', 
-        '1999-01-01', '1999-01-02', '1999-02-01', '1999-02-02', '1999-03-01', '1999-03-02', 
-        '1999-04-01', '1999-04-02', '1999-05-01', '1999-05-02', '1999-06-01', '1999-06-02', 
-        '1999-07-01', '1999-07-02', '1999-08-01', '1999-08-02', '1999-09-01', '1999-09-02', 
-        '1999-10-01', '1999-10-02', '1999-11-01', '1999-11-02', '1999-12-01', '1999-12-02', 
-        '2000-01-01', '2000-01-02', '2000-02-01', '2000-02-02', '2000-03-01', '2000-03-02', 
-        '2000-04-01', '2000-04-02', '2000-05-01', '2000-05-02', '2000-06-01', '2000-06-02', 
-        '2000-07-01', '2000-07-02', '2000-08-01', '2000-08-02', '2000-09-01', '2000-09-02', 
-        '2000-10-01', '2000-10-02', '2000-11-01', '2000-11-02', '2000-12-01', '2000-12-02'
-    )
-    and store.s_county in ('Kittitas County','Adams County','Richland County','Furnas County')
-    group by ss_ticket_number,ss_customer_sk) dj,customer
-    where dj.ss_customer_sk = customer.c_customer_sk
-      and cnt between 1 and 5
-    order by cnt desc;
-
-

+ 0 - 24
sample-queries/query76.sql

@@ -1,24 +0,0 @@
-
-select  channel, col_name, d_year, d_qoy, i_category, COUNT(*) sales_cnt, SUM(ext_sales_price) sales_amt FROM (
-        SELECT 'store' as channel, 'ss_addr_sk' col_name, d_year, d_qoy, i_category, ss_ext_sales_price ext_sales_price
-         FROM store_sales, item, date_dim
-         WHERE ss_addr_sk IS NULL
-           AND store_sales.ss_sold_date_sk=date_dim.d_date_sk
-           AND store_sales.ss_item_sk=item.i_item_sk
-        UNION ALL
-        SELECT 'web' as channel, 'ws_web_page_sk' col_name, d_year, d_qoy, i_category, ws_ext_sales_price ext_sales_price
-         FROM web_sales, item, date_dim
-         WHERE ws_web_page_sk IS NULL
-           AND web_sales.ws_sold_date_sk=date_dim.d_date_sk
-           AND web_sales.ws_item_sk=item.i_item_sk
-        UNION ALL
-        SELECT 'catalog' as channel, 'cs_warehouse_sk' col_name, d_year, d_qoy, i_category, cs_ext_sales_price ext_sales_price
-         FROM catalog_sales, item, date_dim
-         WHERE cs_warehouse_sk IS NULL
-           AND catalog_sales.cs_sold_date_sk=date_dim.d_date_sk
-           AND catalog_sales.cs_item_sk=item.i_item_sk) foo
-GROUP BY channel, col_name, d_year, d_qoy, i_category
-ORDER BY channel, col_name, d_year, d_qoy, i_category
-limit 100;
-
-

+ 0 - 51
sample-queries/query79.sql

@@ -1,51 +0,0 @@
-
-select 
-  c_last_name,c_first_name,substr(s_city,1,30) sub,ss_ticket_number,amt,profit
-  from
-   (select ss_ticket_number
-          ,ss_customer_sk
-          ,store.s_city
-          ,sum(ss_coupon_amt) amt
-          ,sum(ss_net_profit) profit
-    from store_sales,date_dim,store,household_demographics
-    where store_sales.ss_sold_date_sk = date_dim.d_date_sk
-    and store_sales.ss_store_sk = store.s_store_sk  
-    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-    and (household_demographics.hd_dep_count = 8 or household_demographics.hd_vehicle_count > 0)
-    and date_dim.d_dow = 1
-    and date_dim.d_year in (1998,1998+1,1998+2) 
-    and store.s_number_employees between 200 and 295
-    and ss_sold_date in (
-        '1998-01-05', '1998-01-12', '1998-01-19', '1998-01-26', '1998-02-02', '1998-02-09', 
-        '1998-02-16', '1998-02-23', '1998-03-02', '1998-03-09', '1998-03-16', '1998-03-23', 
-        '1998-03-30', '1998-04-06', '1998-04-13', '1998-04-20', '1998-04-27', '1998-05-04', 
-        '1998-05-11', '1998-05-18', '1998-05-25', '1998-06-01', '1998-06-08', '1998-06-15', 
-        '1998-06-22', '1998-06-29', '1998-07-06', '1998-07-13', '1998-07-20', '1998-07-27', 
-        '1998-08-03', '1998-08-10', '1998-08-17', '1998-08-24', '1998-08-31', '1998-09-07', 
-        '1998-09-14', '1998-09-21', '1998-09-28', '1998-10-05', '1998-10-12', '1998-10-19', 
-        '1998-10-26', '1998-11-02', '1998-11-09', '1998-11-16', '1998-11-23', '1998-11-30', 
-        '1998-12-07', '1998-12-14', '1998-12-21', '1998-12-28', '1999-01-04', '1999-01-11', 
-        '1999-01-18', '1999-01-25', '1999-02-01', '1999-02-08', '1999-02-15', '1999-02-22', 
-        '1999-03-01', '1999-03-08', '1999-03-15', '1999-03-22', '1999-03-29', '1999-04-05', 
-        '1999-04-12', '1999-04-19', '1999-04-26', '1999-05-03', '1999-05-10', '1999-05-17', 
-        '1999-05-24', '1999-05-31', '1999-06-07', '1999-06-14', '1999-06-21', '1999-06-28', 
-        '1999-07-05', '1999-07-12', '1999-07-19', '1999-07-26', '1999-08-02', '1999-08-09', 
-        '1999-08-16', '1999-08-23', '1999-08-30', '1999-09-06', '1999-09-13', '1999-09-20', 
-        '1999-09-27', '1999-10-04', '1999-10-11', '1999-10-18', '1999-10-25', '1999-11-01', 
-        '1999-11-08', '1999-11-15', '1999-11-22', '1999-11-29', '1999-12-06', '1999-12-13', 
-        '1999-12-20', '1999-12-27', '2000-01-03', '2000-01-10', '2000-01-17', '2000-01-24', 
-        '2000-01-31', '2000-02-07', '2000-02-14', '2000-02-21', '2000-02-28', '2000-03-06', 
-        '2000-03-13', '2000-03-20', '2000-03-27', '2000-04-03', '2000-04-10', '2000-04-17', 
-        '2000-04-24', '2000-05-01', '2000-05-08', '2000-05-15', '2000-05-22', '2000-05-29', 
-        '2000-06-05', '2000-06-12', '2000-06-19', '2000-06-26', '2000-07-03', '2000-07-10', 
-        '2000-07-17', '2000-07-24', '2000-07-31', '2000-08-07', '2000-08-14', '2000-08-21', 
-        '2000-08-28', '2000-09-04', '2000-09-11', '2000-09-18', '2000-09-25', '2000-10-02', 
-        '2000-10-09', '2000-10-16', '2000-10-23', '2000-10-30', '2000-11-06', '2000-11-13', 
-        '2000-11-20', '2000-11-27', '2000-12-04', '2000-12-11', '2000-12-18', '2000-12-25'
-    )
-    group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer
-    where ms.ss_customer_sk = customer.c_customer_sk
- order by c_last_name,c_first_name,sub, profit
-limit 100;
-
-

+ 0 - 21
sample-queries/query84.sql

@@ -1,21 +0,0 @@
-
-select  c_customer_id as customer_id
-       ,concat(c_last_name, ', ', c_first_name) as customername
- from customer
-     ,customer_address
-     ,customer_demographics
-     ,household_demographics
-     ,income_band
-     ,store_returns
- where ca_city	        =  'Hopewell'
-   and customer.c_current_addr_sk = customer_address.ca_address_sk
-   and ib_lower_bound   >=  32287
-   and ib_upper_bound   <=  32287 + 50000
-   and income_band.ib_income_band_sk = household_demographics.hd_income_band_sk
-   and customer_demographics.cd_demo_sk = customer.c_current_cdemo_sk
-   and household_demographics.hd_demo_sk = customer.c_current_hdemo_sk
-   and store_returns.sr_cdemo_sk = customer_demographics.cd_demo_sk
- order by customer_id
- limit 100;
-
-

+ 0 - 82
sample-queries/query85.sql

@@ -1,82 +0,0 @@
-
-select  substr(r_reason_desc,1,20) as r
-       ,avg(ws_quantity) wq
-       ,avg(wr_refunded_cash) ref
-       ,avg(wr_fee) fee
- from web_sales, web_returns, web_page, customer_demographics cd1,
-      customer_demographics cd2, customer_address, date_dim, reason 
- where web_sales.ws_web_page_sk = web_page.wp_web_page_sk
-   and web_sales.ws_item_sk = web_returns.wr_item_sk
-   and web_sales.ws_order_number = web_returns.wr_order_number
-   and web_sales.ws_sold_date_sk = date_dim.d_date_sk and d_year = 1998
-   and web_sales.ws_sold_date between '1998-01-01' and '1998-12-31'
-   and cd1.cd_demo_sk = web_returns.wr_refunded_cdemo_sk 
-   and cd2.cd_demo_sk = web_returns.wr_returning_cdemo_sk
-   and customer_address.ca_address_sk = web_returns.wr_refunded_addr_sk
-   and reason.r_reason_sk = web_returns.wr_reason_sk
-   and
-   (
-    (
-     cd1.cd_marital_status = 'M'
-     and
-     cd1.cd_marital_status = cd2.cd_marital_status
-     and
-     cd1.cd_education_status = '4 yr Degree'
-     and 
-     cd1.cd_education_status = cd2.cd_education_status
-     and
-     ws_sales_price between 100.00 and 150.00
-    )
-   or
-    (
-     cd1.cd_marital_status = 'D'
-     and
-     cd1.cd_marital_status = cd2.cd_marital_status
-     and
-     cd1.cd_education_status = 'Primary' 
-     and
-     cd1.cd_education_status = cd2.cd_education_status
-     and
-     ws_sales_price between 50.00 and 100.00
-    )
-   or
-    (
-     cd1.cd_marital_status = 'U'
-     and
-     cd1.cd_marital_status = cd2.cd_marital_status
-     and
-     cd1.cd_education_status = 'Advanced Degree'
-     and
-     cd1.cd_education_status = cd2.cd_education_status
-     and
-     ws_sales_price between 150.00 and 200.00
-    )
-   )
-   and
-   (
-    (
-     ca_country = 'United States'
-     and
-     ca_state in ('KY', 'GA', 'NM')
-     and ws_net_profit between 100 and 200  
-    )
-    or
-    (
-     ca_country = 'United States'
-     and
-     ca_state in ('MT', 'OR', 'IN')
-     and ws_net_profit between 150 and 300  
-    )
-    or
-    (
-     ca_country = 'United States'
-     and
-     ca_state in ('WI', 'MO', 'WV')
-     and ws_net_profit between 50 and 250  
-    )
-   )
-group by r_reason_desc
-order by r, wq, ref, fee
-limit 100;
-
-

+ 0 - 36
sample-queries/query87.sql

@@ -1,36 +0,0 @@
-select count(*) 
-from (select distinct c_last_name as l1, c_first_name as f1, d_date as d1
-       from store_sales
-        JOIN date_dim ON store_sales.ss_sold_date_sk = date_dim.d_date_sk
-        JOIN customer ON store_sales.ss_customer_sk = customer.c_customer_sk
-       where 
-         d_month_seq between 1193 and 1193+11
-         and ss_sold_date between '1999-06-01' and '2000-05-31'
-	) t1
-      LEFT OUTER JOIN
-      ( select distinct c_last_name as l2, c_first_name as f2, d_date as d2
-       from catalog_sales
-        JOIN date_dim ON catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
-        JOIN customer ON catalog_sales.cs_bill_customer_sk = customer.c_customer_sk
-       where 
-         d_month_seq between 1193 and 1193+11
-         and cs_sold_date between '1999-06-01' and '2000-05-31'
-	) t2
-      ON t1.l1 = t2.l2 and
-       t1.f1 = t2.f2 and
-       t1.d1 = t2.d2
-      LEFT OUTER JOIN
-      (select distinct c_last_name as l3, c_first_name as f3, d_date as d3
-       from web_sales
-        JOIN date_dim ON web_sales.ws_sold_date_sk = date_dim.d_date_sk
-        JOIN customer ON web_sales.ws_bill_customer_sk = customer.c_customer_sk
-       where 
-         d_month_seq between 1193 and 1193+11
-         and ws_sold_date between '1999-06-01' and '2000-05-31'
-	) t3
-      ON t1.l1 = t3.l3 and
-       t1.f1 = t3.f3 and
-       t1.d1 = t3.d3
-WHERE
-    l2 is null and
-    l3 is null ;

+ 0 - 94
sample-queries/query88.sql

@@ -1,94 +0,0 @@
-
-select  *
-from
- (select count(*) h8_30_to_9
- from store_sales, household_demographics , time_dim, store
- where store_sales.ss_sold_time_sk = time_dim.t_time_sk   
-     and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk 
-     and store_sales.ss_store_sk = store.s_store_sk
-     and time_dim.t_hour = 8
-     and time_dim.t_minute >= 30
-     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
-          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
-          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2)) 
-     and store.s_store_name = 'ese') s1,
- (select count(*) h9_to_9_30 
- from store_sales, household_demographics , time_dim, store
- where store_sales.ss_sold_time_sk = time_dim.t_time_sk
-     and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-     and store_sales.ss_store_sk = store.s_store_sk 
-     and time_dim.t_hour = 9 
-     and time_dim.t_minute < 30
-     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
-          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
-          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
-     and store.s_store_name = 'ese') s2,
- (select count(*) h9_30_to_10 
- from store_sales, household_demographics , time_dim, store
- where store_sales.ss_sold_time_sk = time_dim.t_time_sk
-     and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-     and store_sales.ss_store_sk = store.s_store_sk
-     and time_dim.t_hour = 9
-     and time_dim.t_minute >= 30
-     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
-          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
-          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
-     and store.s_store_name = 'ese') s3,
- (select count(*) h10_to_10_30
- from store_sales, household_demographics , time_dim, store
- where store_sales.ss_sold_time_sk = time_dim.t_time_sk
-     and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-     and store_sales.ss_store_sk = store.s_store_sk
-     and time_dim.t_hour = 10 
-     and time_dim.t_minute < 30
-     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
-          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
-          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
-     and store.s_store_name = 'ese') s4,
- (select count(*) h10_30_to_11
- from store_sales, household_demographics , time_dim, store
- where store_sales.ss_sold_time_sk = time_dim.t_time_sk
-     and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-     and store_sales.ss_store_sk = store.s_store_sk
-     and time_dim.t_hour = 10 
-     and time_dim.t_minute >= 30
-     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
-          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
-          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
-     and store.s_store_name = 'ese') s5,
- (select count(*) h11_to_11_30
- from store_sales, household_demographics , time_dim, store
- where store_sales.ss_sold_time_sk = time_dim.t_time_sk
-     and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-     and store_sales.ss_store_sk = store.s_store_sk 
-     and time_dim.t_hour = 11
-     and time_dim.t_minute < 30
-     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
-          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
-          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
-     and store.s_store_name = 'ese') s6,
- (select count(*) h11_30_to_12
- from store_sales, household_demographics , time_dim, store
- where store_sales.ss_sold_time_sk = time_dim.t_time_sk
-     and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-     and store_sales.ss_store_sk = store.s_store_sk
-     and time_dim.t_hour = 11
-     and time_dim.t_minute >= 30
-     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
-          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
-          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
-     and store.s_store_name = 'ese') s7,
- (select count(*) h12_to_12_30
- from store_sales, household_demographics , time_dim, store
- where store_sales.ss_sold_time_sk = time_dim.t_time_sk
-     and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk
-     and store_sales.ss_store_sk = store.s_store_sk
-     and time_dim.t_hour = 12
-     and time_dim.t_minute < 30
-     and ((household_demographics.hd_dep_count = 3 and household_demographics.hd_vehicle_count<=3+2) or
-          (household_demographics.hd_dep_count = 0 and household_demographics.hd_vehicle_count<=0+2) or
-          (household_demographics.hd_dep_count = 1 and household_demographics.hd_vehicle_count<=1+2))
-     and store.s_store_name = 'ese') s8
-;
-
-

+ 0 - 29
sample-queries/query89.sql

@@ -1,29 +0,0 @@
-
-select  *
-from(
-select i_category, i_class, i_brand,
-       s_store_name, s_company_name,
-       d_moy,
-       sum(ss_sales_price) sum_sales,
-       avg(sum(ss_sales_price)) over
-         (partition by i_category, i_brand, s_store_name, s_company_name)
-         avg_monthly_sales
-from item, store_sales, date_dim, store
-where store_sales.ss_item_sk = item.i_item_sk and
-      store_sales.ss_sold_date_sk = date_dim.d_date_sk and
-      store_sales.ss_store_sk = store.s_store_sk and
-      store_sales.ss_sold_date between '2000-01-01' and '2000-12-31' and
-      d_year in (2000) and
-        ((i_category in ('Home','Books','Electronics') and
-          i_class in ('wallpaper','parenting','musical')
-         )
-      or (i_category in ('Shoes','Jewelry','Men') and
-          i_class in ('womens','birdal','pants') 
-        ))
-group by i_category, i_class, i_brand,
-         s_store_name, s_company_name, d_moy) tmp1
-where case when (avg_monthly_sales <> 0) then (abs(sum_sales - avg_monthly_sales) / avg_monthly_sales) else null end > 0.1
-order by sum_sales - avg_monthly_sales, s_store_name
-limit 100;
-
-

+ 0 - 22
sample-queries/query90.sql

@@ -1,22 +0,0 @@
-
-select  cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio
- from ( select count(*) amc
-       from web_sales, household_demographics , time_dim, web_page
-       where ws_sold_time_sk = time_dim.t_time_sk
-         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
-         and ws_web_page_sk = web_page.wp_web_page_sk
-         and time_dim.t_hour between 6 and 6+1
-         and household_demographics.hd_dep_count = 8
-         and web_page.wp_char_count between 5000 and 5200) at,
-      ( select count(*) pmc
-       from web_sales, household_demographics , time_dim, web_page
-       where ws_sold_time_sk = time_dim.t_time_sk
-         and ws_ship_hdemo_sk = household_demographics.hd_demo_sk
-         and ws_web_page_sk = web_page.wp_web_page_sk
-         and time_dim.t_hour between 14 and 14+1
-         and household_demographics.hd_dep_count = 8
-         and web_page.wp_char_count between 5000 and 5200) pt
- order by am_pm_ratio
- limit 100;
-
-

+ 0 - 32
sample-queries/query91.sql

@@ -1,32 +0,0 @@
-
-select  
-        cc_call_center_id Call_Center,
-        cc_name Call_Center_Name,
-        cc_manager Manager,
-        sum(cr_net_loss) Returns_Loss
-from
-        call_center,
-        catalog_returns,
-        date_dim,
-        customer,
-        customer_address,
-        customer_demographics,
-        household_demographics
-where
-        catalog_returns.cr_call_center_sk       = call_center.cc_call_center_sk
-and     catalog_returns.cr_returned_date_sk     = date_dim.d_date_sk
-and     catalog_returns.cr_returning_customer_sk= customer.c_customer_sk
-and     customer_demographics.cd_demo_sk              = customer.c_current_cdemo_sk
-and     household_demographics.hd_demo_sk              = customer.c_current_hdemo_sk
-and     customer_address.ca_address_sk           = customer.c_current_addr_sk
-and     d_year                  = 1999 
-and     d_moy                   = 11
-and	cr_returned_date	between '1999-11-01' and '1999-11-31'
-and     ( (cd_marital_status       = 'M' and cd_education_status     = 'Unknown')
-        or(cd_marital_status       = 'W' and cd_education_status     = 'Advanced Degree'))
-and     hd_buy_potential like '0-500%'
-and     ca_gmt_offset           = -7
-group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status
-order by Returns_Loss desc;
-
-

+ 0 - 24
sample-queries/query92.sql

@@ -1,24 +0,0 @@
-SELECT sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1
-                                 else 0 end) as store_only,
-               sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1
-                                else 0 end) as catalog_only,
-               sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 
-                                 else 0 end) as store_and_catalog
-FROM (SELECT ss.ss_customer_sk as customer_sk,
-                             ss.ss_item_sk as item_sk
-             FROM store_sales ss
-             JOIN date_dim d1 ON (ss.ss_sold_date_sk = d1.d_date_sk)
-             WHERE d1.d_month_seq >= 1206 and
-                            d1.d_month_seq <= 1217
-	     and ss_sold_date between '2000-07-01' and '2000-06-30'
-             GROUP BY ss.ss_customer_sk, ss.ss_item_sk) ssci
-FULL OUTER JOIN (SELECT cs.cs_bill_customer_sk as customer_sk,
-                                                   cs.cs_item_sk as item_sk
-                                   FROM catalog_sales cs
-                                   JOIN date_dim d2 ON (cs.cs_sold_date_sk = d2.d_date_sk)
-                                   WHERE d2.d_month_seq >= 1206 and
-                                                  d2.d_month_seq <= 1217
-				   and cs_sold_date between '2000-07-01' and '2000-06-30'
-                                   GROUP BY cs.cs_bill_customer_sk, cs.cs_item_sk) csci
-ON (ssci.customer_sk=csci.customer_sk and
-        ssci.item_sk = csci.item_sk);

+ 0 - 18
sample-queries/query93.sql

@@ -1,18 +0,0 @@
-
-select  ss_customer_sk
-            ,sum(act_sales) sumsales
-      from (select ss_item_sk
-                  ,ss_ticket_number
-                  ,ss_customer_sk
-                  ,case when sr_return_quantity is not null then (ss_quantity-sr_return_quantity)*ss_sales_price
-                                                            else (ss_quantity*ss_sales_price) end act_sales
-            from store_sales left outer join store_returns on (store_returns.sr_item_sk = store_sales.ss_item_sk
-                                                               and store_returns.sr_ticket_number = store_sales.ss_ticket_number)
-                ,reason
-            where store_returns.sr_reason_sk = reason.r_reason_sk
-              and r_reason_desc = 'Did not like the warranty') t
-      group by ss_customer_sk
-      order by sumsales, ss_customer_sk
-limit 100;
-
-

+ 0 - 22
sample-queries/query94.sql

@@ -1,22 +0,0 @@
-SELECT count(distinct ws_order_number) as order_count,
-               sum(ws_ext_ship_cost) as total_shipping_cost,
-               sum(ws_net_profit) as total_net_profit
-FROM web_sales ws1
-JOIN customer_address ca ON (ws1.ws_ship_addr_sk = ca.ca_address_sk)
-JOIN web_site s ON (ws1.ws_web_site_sk = s.web_site_sk)
-JOIN date_dim d ON (ws1.ws_ship_date_sk = d.d_date_sk)
-LEFT SEMI JOIN (SELECT ws2.ws_order_number as ws_order_number
-                               FROM web_sales ws2 JOIN web_sales ws3
-                               ON (ws2.ws_order_number = ws3.ws_order_number)
-                               WHERE ws2.ws_warehouse_sk <> ws3.ws_warehouse_sk
-			       and ws2.ws_sold_date between '1999-5-01' and '1999-7-01'
-			       and ws3.ws_sold_date between '1999-5-01' and '1999-7-01'
-			) ws_wh1
-ON (ws1.ws_order_number = ws_wh1.ws_order_number)
-LEFT OUTER JOIN web_returns wr1 ON (ws1.ws_order_number = wr1.wr_order_number)
-WHERE d.d_date between '1999-5-01' and '1999-7-01' and
-	       ws_sold_date between '1999-5-01' and '1999-7-01' and
-               ca.ca_state = 'TX' and
-               s.web_company_name = 'pri' and
-               wr1.wr_order_number is null
-limit 100;

+ 0 - 30
sample-queries/query95.sql

@@ -1,30 +0,0 @@
-SELECT count(distinct ws1.ws_order_number) as order_count,
-               sum(ws1.ws_ext_ship_cost) as total_shipping_cost,
-               sum(ws1.ws_net_profit) as total_net_profit
-FROM web_sales ws1
-JOIN customer_address ca ON (ws1.ws_ship_addr_sk = ca.ca_address_sk)
-JOIN web_site s ON (ws1.ws_web_site_sk = s.web_site_sk)
-JOIN date_dim d ON (ws1.ws_ship_date_sk = d.d_date_sk)
-LEFT SEMI JOIN (SELECT ws2.ws_order_number as ws_order_number
-                               FROM web_sales ws2 JOIN web_sales ws3
-                               ON (ws2.ws_order_number = ws3.ws_order_number)
-                               WHERE ws2.ws_warehouse_sk <> ws3.ws_warehouse_sk
-			       and ws2.ws_sold_date between '2002-5-01' and '2002-6-30'
-			       and ws3.ws_sold_date between '2002-5-01' and '2002-6-30'
-			) ws_wh1
-ON (ws1.ws_order_number = ws_wh1.ws_order_number)
-LEFT SEMI JOIN (SELECT wr_order_number
-                               FROM web_returns wr
-                               JOIN (SELECT ws4.ws_order_number as ws_order_number
-                                          FROM web_sales ws4 JOIN web_sales ws5
-                                          ON (ws4.ws_order_number = ws5.ws_order_number)
-                                         WHERE ws4.ws_warehouse_sk <> ws5.ws_warehouse_sk
-					 and ws4.ws_sold_date between '2002-5-01' and '2002-6-30'
-					 and ws5.ws_sold_date between '2002-5-01' and '2002-6-30'
-				) ws_wh2
-                               ON (wr.wr_order_number = ws_wh2.ws_order_number)) tmp1
-ON (ws1.ws_order_number = tmp1.wr_order_number)
-WHERE d.d_date between '2002-5-01' and '2002-6-30' and
-	       ws_sold_date  between '2002-5-01' and '2002-6-30' and
-               ca.ca_state = 'GA' and
-               s.web_company_name = 'pri';

+ 0 - 16
sample-queries/query96.sql

@@ -1,16 +0,0 @@
-
-select  count(*) as c
-from store_sales
-    ,household_demographics 
-    ,time_dim, store
-where store_sales.ss_sold_time_sk = time_dim.t_time_sk   
-    and store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk 
-    and store_sales.ss_store_sk = store.s_store_sk
-    and time_dim.t_hour = 8
-    and time_dim.t_minute >= 30
-    and household_demographics.hd_dep_count = 5
-    and store.s_store_name = 'ese'
-order by c
-limit 100;
-
-

+ 0 - 24
sample-queries/query97.sql

@@ -1,24 +0,0 @@
-select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only
-      ,sum(case when ssci.customer_sk is null and csci.customer_sk is not null then 1 else 0 end) catalog_only
-      ,sum(case when ssci.customer_sk is not null and csci.customer_sk is not null then 1 else 0 end) store_and_catalog
-from 
-( select ss_customer_sk customer_sk
-      ,ss_item_sk item_sk
-from store_sales
-JOIN date_dim ON store_sales.ss_sold_date_sk = date_dim.d_date_sk
-where
-  d_month_seq between 1193 and 1193 + 11
-  and ss_sold_date between '1999-06-01' and '2000-05-31'
-group by ss_customer_sk ,ss_item_sk) ssci
-full outer join
-( select cs_bill_customer_sk customer_sk
-      ,cs_item_sk item_sk
-from catalog_sales
-JOIN date_dim ON catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
-where
-  d_month_seq between 1193 and 1193 + 11
-  and cs_sold_date between '1999-06-01' and '2000-05-31'
-group by cs_bill_customer_sk ,cs_item_sk) csci
-on (ssci.customer_sk=csci.customer_sk and ssci.item_sk = csci.item_sk)
-limit 100;
-

+ 0 - 34
sample-queries/query98.sql

@@ -1,34 +0,0 @@
-
-select i_item_desc 
-      ,i_category 
-      ,i_class 
-      ,i_current_price
-      ,i_item_id
-      ,sum(ss_ext_sales_price) as itemrevenue 
-      ,sum(ss_ext_sales_price)*100/sum(sum(ss_ext_sales_price)) over
-          (partition by i_class) as revenueratio
-from	
-	store_sales
-    	,item 
-    	,date_dim
-where 
-	store_sales.ss_item_sk = item.i_item_sk 
-  	and i_category in ('Jewelry', 'Sports', 'Books')
-  	and store_sales.ss_sold_date_sk = date_dim.d_date_sk
-	and d_date between cast('2001-01-12' as date) 
-				and (cast('2001-02-11' as date))
-	and ss_sold_date between '2001-01-12' and '2001-02-11'
-group by 
-	i_item_id
-        ,i_item_desc 
-        ,i_category
-        ,i_class
-        ,i_current_price
-order by 
-	i_category
-        ,i_class
-        ,i_item_id
-        ,i_item_desc
-        ,revenueratio;
-
-