Browse Source

Removing the trivial rewrites and using original tpcds query.

Nita Dembla 7 years ago
parent
commit
6dd2422e1d

+ 1 - 1
sample-queries-tpcds/query12.sql

@@ -16,7 +16,7 @@ where
   	and i_category in ('Jewelry', 'Sports', 'Books')
   	and ws_sold_date_sk = d_date_sk
 	and d_date between cast('2001-01-12' as date) 
-				and (cast('2001-01-12' as date) + interval '30' days)
+				and (cast('2001-01-12' as date) + 30 days)
 group by 
 	i_item_id
         ,i_item_desc 

+ 2 - 2
sample-queries-tpcds/query16.sql

@@ -10,7 +10,7 @@ from
   ,call_center
 where
     d_date between '2001-4-01' and 
-           (cast('2001-4-01' as date) + interval '60' days)
+           (cast('2001-4-01' as date) + 60 days)
 and cs1.cs_ship_date_sk = d_date_sk
 and cs1.cs_ship_addr_sk = ca_address_sk
 and ca_state = 'NY'
@@ -25,7 +25,7 @@ and exists (select *
 and not exists(select *
                from catalog_returns cr1
                where cs1.cs_order_number = cr1.cr_order_number)
-order by `order count`
+order by count(distinct cs_order_number)
 limit 100;
 
 -- end query 1 in stream 0 using template query16.tpl

+ 7 - 7
sample-queries-tpcds/query18.sql

@@ -3,13 +3,13 @@ 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
+        avg( cast(cs_quantity as numeric(12,2))) agg1,
+        avg( cast(cs_list_price as numeric(12,2))) agg2,
+        avg( cast(cs_coupon_amt as numeric(12,2))) agg3,
+        avg( cast(cs_sales_price as numeric(12,2))) agg4,
+        avg( cast(cs_net_profit as numeric(12,2))) agg5,
+        avg( cast(c_birth_year as numeric(12,2))) agg6,
+        avg( cast(cd1.cd_dep_count as numeric(12,2))) agg7
  from catalog_sales, customer_demographics cd1, 
       customer_demographics cd2, customer, customer_address, date_dim, item
  where cs_sold_date_sk = d_date_sk and

+ 1 - 2
sample-queries-tpcds/query20.sql

@@ -3,7 +3,6 @@ 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
@@ -14,7 +13,7 @@ select  i_item_desc
    and i_category in ('Jewelry', 'Sports', 'Books')
    and cs_sold_date_sk = d_date_sk
  and d_date between cast('2001-01-12' as date) 
- 				and (cast('2001-01-12' as date) + interval '30' days)
+ 				and (cast('2001-01-12' as date) + 30 days)
  group by i_item_id
          ,i_item_desc 
          ,i_category

+ 2 - 2
sample-queries-tpcds/query21.sql

@@ -16,8 +16,8 @@ select  *
      and i_item_sk          = inv_item_sk
      and inv_warehouse_sk   = w_warehouse_sk
      and inv_date_sk    = d_date_sk
-     and d_date between (cast ('1998-04-08' as date) - interval '30' days)
-                    and (cast ('1998-04-08' as date) + interval '30' days)
+     and d_date between (cast ('1998-04-08' as date) - 30 days)
+                    and (cast ('1998-04-08' as date) + 30 days)
    group by w_warehouse_name, i_item_id) x
  where (case when inv_before > 0 
              then inv_after / inv_before 

+ 1 - 1
sample-queries-tpcds/query31.sql

@@ -11,7 +11,7 @@ with ss as
  where ws_sold_date_sk = d_date_sk
   and ws_bill_addr_sk=ca_address_sk
  group by ca_county,d_qoy, d_year)
- select
+ select /* tt */
         ss1.ca_county
        ,ss1.d_year
        ,ws2.web_sales/ws1.web_sales web_q1_q2_increase

+ 2 - 2
sample-queries-tpcds/query32.sql

@@ -8,7 +8,7 @@ where
 i_manufact_id = 269
 and i_item_sk = cs_item_sk 
 and d_date between '1998-03-18' and 
-        (cast('1998-03-18' as date) + interval '90' days)
+        (cast('1998-03-18' as date) + 90 days)
 and d_date_sk = cs_sold_date_sk 
 and cs_ext_discount_amt  
      > ( 
@@ -20,7 +20,7 @@ and cs_ext_discount_amt
          where 
               cs_item_sk = i_item_sk 
           and d_date between '1998-03-18' and
-                             (cast('1998-03-18' as date) + interval '90' days)
+                             (cast('1998-03-18' as date) + 90 days)
           and d_date_sk = cs_sold_date_sk 
       ) 
 limit 100;

+ 0 - 1
sample-queries-tpcds/query35.sql

@@ -3,7 +3,6 @@ select
   ca_state,
   cd_gender,
   cd_marital_status,
-  cd_dep_count,
   count(*) cnt1,
   avg(cd_dep_count),
   max(cd_dep_count),

+ 1 - 1
sample-queries-tpcds/query37.sql

@@ -6,7 +6,7 @@ select  i_item_id
  where i_current_price between 22 and 22 + 30
  and inv_item_sk = i_item_sk
  and d_date_sk=inv_date_sk
- and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) +  interval '60' days)
+ and d_date between cast('2001-06-02' as date) and (cast('2001-06-02' as date) +  60 days)
  and i_manufact_id in (678,964,918,849)
  and inv_quantity_on_hand between 100 and 500
  and cs_item_sk = i_item_sk

+ 2 - 2
sample-queries-tpcds/query40.sql

@@ -18,8 +18,8 @@ select
  and i_item_sk          = cs_item_sk
  and cs_warehouse_sk    = w_warehouse_sk 
  and cs_sold_date_sk    = d_date_sk
- and d_date between (cast ('1998-04-08' as date) - interval '30' days)
-                and (cast ('1998-04-08' as date) + interval '30' days) 
+ and d_date between (cast ('1998-04-08' as date) - 30 days)
+                and (cast ('1998-04-08' as date) + 30 days) 
  group by
     w_state,i_item_id
  order by w_state,i_item_id

+ 9 - 6
sample-queries-tpcds/query41.sql

@@ -1,4 +1,6 @@
-select  distinct(i_product_name) from item i1
+-- start query 1 in stream 0 using template query41.tpl and seed 1581015815
+select  distinct(i_product_name)
+ from item i1
  where i_manufact_id between 742 and 742+40 
    and (select count(*) as item_cnt
         from item
@@ -22,10 +24,8 @@ select  distinct(i_product_name) from item i1
         (i_color = 'chocolate' or i_color = 'cornflower') and
         (i_units = 'Bunch' or i_units = 'Gross') and
         (i_size = 'petite' or i_size = 'medium')
-        )))) > 0
-   or (select count(*) as item_cnt
-       from item
-       where (i_manufact = i1.i_manufact and
+        ))) or
+       (i_manufact = i1.i_manufact and
         ((i_category = 'Women' and 
         (i_color = 'salmon' or i_color = 'midnight') and 
         (i_units = 'Oz' or i_units = 'Box') and
@@ -46,4 +46,7 @@ select  distinct(i_product_name) from item i1
         (i_units = 'Gram' or i_units = 'Ounce') and
         (i_size = 'petite' or i_size = 'medium')
         )))) > 0
- order by i_product_name limit 100;
+ order by i_product_name
+ limit 100;
+
+-- end query 1 in stream 0 using template query41.tpl

+ 2 - 2
sample-queries-tpcds/query42.sql

@@ -2,7 +2,7 @@
 select  dt.d_year
  	,item.i_category_id
  	,item.i_category
- 	,sum(ss_ext_sales_price) sp
+ 	,sum(ss_ext_sales_price)
  from 	date_dim dt
  	,store_sales
  	,item
@@ -14,7 +14,7 @@ select  dt.d_year
  group by 	dt.d_year
  		,item.i_category_id
  		,item.i_category
- order by       sp desc,dt.d_year
+ order by       sum(ss_ext_sales_price) desc,dt.d_year
  		,item.i_category_id
  		,item.i_category
 limit 100 ;

+ 1 - 1
sample-queries-tpcds/query47.sql

@@ -40,7 +40,7 @@ with v1 as(
        v1.s_company_name = v1_lead.s_company_name and
        v1.rn = v1_lag.rn + 1 and
        v1.rn = v1_lead.rn - 1)
-  select  i_category, d_year, d_moy, avg_monthly_sales, sum_sales, psum, nsum
+  select  *
  from v2
  where  d_year = 2000 and    
         avg_monthly_sales > 0 and

+ 10 - 10
sample-queries-tpcds/query49.sql

@@ -14,10 +14,10 @@ select
  	,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
+ 		,(cast(sum(coalesce(wr.wr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(wr.wr_return_amt,0)) as dec(15,4))/
+ 		cast(sum(coalesce(ws.ws_net_paid,0)) as dec(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 
@@ -57,10 +57,10 @@ select
  	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
+ 		,(cast(sum(coalesce(cr.cr_return_quantity,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(cr.cr_return_amount,0)) as dec(15,4))/
+ 		cast(sum(coalesce(cs.cs_net_paid,0)) as dec(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 
@@ -99,8 +99,8 @@ select
  	,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
+ 		,(cast(sum(coalesce(sr.sr_return_quantity,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_quantity,0)) as dec(15,4) )) as return_ratio
+ 		,(cast(sum(coalesce(sr.sr_return_amt,0)) as dec(15,4))/cast(sum(coalesce(sts.ss_net_paid,0)) as dec(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)

+ 3 - 3
sample-queries-tpcds/query5.sql

@@ -26,7 +26,7 @@ with ssr as
      store
  where date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date) 
-                  and (cast('1998-08-04' as date) +  interval '14' days)
+                  and (cast('1998-08-04' as date) +  14 days)
        and store_sk = s_store_sk
  group by s_store_id)
  ,
@@ -57,7 +57,7 @@ with ssr as
      catalog_page
  where date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date)
-                  and (cast('1998-08-04' as date) +  interval '14' days)
+                  and (cast('1998-08-04' as date) +  14 days)
        and page_sk = cp_catalog_page_sk
  group by cp_catalog_page_id)
  ,
@@ -90,7 +90,7 @@ with ssr as
      web_site
  where date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date)
-                  and (cast('1998-08-04' as date) +  interval '14' days)
+                  and (cast('1998-08-04' as date) +  14 days)
        and wsr_web_site_sk = web_site_sk
  group by web_site_id)
   select  channel

+ 6 - 6
sample-queries-tpcds/query50.sql

@@ -1,5 +1,5 @@
 -- start query 1 in stream 0 using template query50.tpl and seed 1819994127
-select /*+ semi(store_returns, sr_ticket_number, store_sales,  34171240)  */
+select  
    s_store_name
   ,s_company_id
   ,s_street_number
@@ -10,14 +10,14 @@ select /*+ semi(store_returns, sr_ticket_number, store_sales,  34171240)  */
   ,s_county
   ,s_state
   ,s_zip
-  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days`
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk <= 30 ) then 1 else 0 end)  as "30 days" 
   ,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 `31-60 days` 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 60) then 1 else 0 end )  as "31-60 days" 
   ,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 `61-90 days`
+                 (sr_returned_date_sk - ss_sold_date_sk <= 90) then 1 else 0 end)  as "61-90 days" 
   ,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 `91-120 days` 
-  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+                 (sr_returned_date_sk - ss_sold_date_sk <= 120) then 1 else 0 end)  as "91-120 days" 
+  ,sum(case when (sr_returned_date_sk - ss_sold_date_sk  > 120) then 1 else 0 end)  as ">120 days" 
 from
    store_sales
   ,store_returns

+ 6 - 10
sample-queries-tpcds/query51.sql

@@ -2,29 +2,25 @@
 WITH web_v1 as (
 select
   ws_item_sk item_sk, d_date,
-  sum(ws_sales_price_s) over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales from (
-select
-  ws_item_sk, d_date,
-  sum(ws_sales_price) ws_sales_price_s
+  sum(sum(ws_sales_price))
+      over (partition by ws_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
 from web_sales
     ,date_dim
 where ws_sold_date_sk=d_date_sk
   and d_month_seq between 1212 and 1212+11
   and ws_item_sk is not NULL
-group by ws_item_sk, d_date) sub1),
+group by ws_item_sk, d_date),
 store_v1 as (
 select
   ss_item_sk item_sk, d_date,
-  sum(ss_sales_price_s) over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales from (
-select
-  ss_item_sk, d_date,
-  sum(ss_sales_price) ss_sales_price_s
+  sum(sum(ss_sales_price))
+      over (partition by ss_item_sk order by d_date rows between unbounded preceding and current row) cume_sales
 from store_sales
     ,date_dim
 where ss_sold_date_sk=d_date_sk
   and d_month_seq between 1212 and 1212+11
   and ss_item_sk is not NULL
-group by ss_item_sk, d_date) sub2)
+group by ss_item_sk, d_date)
  select  *
 from (select item_sk
      ,d_date

+ 1 - 1
sample-queries-tpcds/query57.sql

@@ -37,7 +37,7 @@ with v1 as(
        v1. cc_name = v1_lead. cc_name and
        v1.rn = v1_lag.rn + 1 and
        v1.rn = v1_lead.rn - 1)
-  select  i_category, i_brand, d_year, d_moy, avg_monthly_sales, sum_sales, psum, nsum
+  select  *
  from v2
  where  d_year = 2000 and
         avg_monthly_sales > 0 and

+ 7 - 7
sample-queries-tpcds/query62.sql

@@ -1,16 +1,16 @@
 -- start query 1 in stream 0 using template query62.tpl and seed 1819994127
 select  
-   substr(w_warehouse_name,1,20) ws
+   substr(w_warehouse_name,1,20)
   ,sm_type
   ,web_name
-  ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days`
+  ,sum(case when (ws_ship_date_sk - ws_sold_date_sk <= 30 ) then 1 else 0 end)  as "30 days" 
   ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 30) and 
-                 (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end )  as `31-60 days` 
+                 (ws_ship_date_sk - ws_sold_date_sk <= 60) then 1 else 0 end )  as "31-60 days" 
   ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 60) and 
-                 (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end)  as `61-90 days`
+                 (ws_ship_date_sk - ws_sold_date_sk <= 90) then 1 else 0 end)  as "61-90 days" 
   ,sum(case when (ws_ship_date_sk - ws_sold_date_sk > 90) and
-                 (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end)  as `91-120 days` 
-  ,sum(case when (ws_ship_date_sk - ws_sold_date_sk  > 120) then 1 else 0 end)  as `>120 days` 
+                 (ws_ship_date_sk - ws_sold_date_sk <= 120) then 1 else 0 end)  as "91-120 days" 
+  ,sum(case when (ws_ship_date_sk - ws_sold_date_sk  > 120) then 1 else 0 end)  as ">120 days" 
 from
    web_sales
   ,warehouse
@@ -27,7 +27,7 @@ group by
    substr(w_warehouse_name,1,20)
   ,sm_type
   ,web_name
-order by ws
+order by substr(w_warehouse_name,1,20)
         ,sm_type
        ,web_name
 limit 100;

+ 6 - 6
sample-queries-tpcds/query77.sql

@@ -8,7 +8,7 @@ with ss as
       store
  where ss_sold_date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date) 
-                  and (cast('1998-08-04' as date) +  interval '30' days) 
+                  and (cast('1998-08-04' as date) +  30 days) 
        and ss_store_sk = s_store_sk
  group by s_store_sk)
  ,
@@ -21,7 +21,7 @@ with ss as
       store
  where sr_returned_date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date)
-                  and (cast('1998-08-04' as date) +  interval '30' days)
+                  and (cast('1998-08-04' as date) +  30 days)
        and sr_store_sk = s_store_sk
  group by s_store_sk), 
  cs as
@@ -32,7 +32,7 @@ with ss as
       date_dim
  where cs_sold_date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date)
-                  and (cast('1998-08-04' as date) +  interval '30' days)
+                  and (cast('1998-08-04' as date) +  30 days)
  group by cs_call_center_sk 
  ), 
  cr as
@@ -43,7 +43,7 @@ with ss as
       date_dim
  where cr_returned_date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date)
-                  and (cast('1998-08-04' as date) +  interval '30' days)
+                  and (cast('1998-08-04' as date) +  30 days)
  ), 
  ws as
  ( select wp_web_page_sk,
@@ -54,7 +54,7 @@ with ss as
       web_page
  where ws_sold_date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date)
-                  and (cast('1998-08-04' as date) +  interval '30' days)
+                  and (cast('1998-08-04' as date) +  30 days)
        and ws_web_page_sk = wp_web_page_sk
  group by wp_web_page_sk), 
  wr as
@@ -66,7 +66,7 @@ with ss as
       web_page
  where wr_returned_date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date)
-                  and (cast('1998-08-04' as date) +  interval '30' days)
+                  and (cast('1998-08-04' as date) +  30 days)
        and wr_web_page_sk = wp_web_page_sk
  group by wp_web_page_sk)
   select  channel

+ 2 - 2
sample-queries-tpcds/query78.sql

@@ -36,7 +36,7 @@ ss as
    group by d_year, ss_item_sk, ss_customer_sk
    )
  select 
-ss_sold_year, ss_item_sk, ss_customer_sk, ss_qty, ss_wc, ss_sp, ws_qty, cs_qty,
+ss_sold_year, ss_item_sk, ss_customer_sk,
 round(ss_qty/(coalesce(ws_qty+cs_qty,1)),2) ratio,
 ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price,
 coalesce(ws_qty,0)+coalesce(cs_qty,0) other_chan_qty,
@@ -44,7 +44,7 @@ coalesce(ws_wc,0)+coalesce(cs_wc,0) other_chan_wholesale_cost,
 coalesce(ws_sp,0)+coalesce(cs_sp,0) other_chan_sales_price
 from ss
 left join ws on (ws_sold_year=ss_sold_year and ws_item_sk=ss_item_sk and ws_customer_sk=ss_customer_sk)
-left join cs on (cs_sold_year=ss_sold_year and ss_item_sk=cs_item_sk and cs_customer_sk=ss_customer_sk)
+left join cs on (cs_sold_year=ss_sold_year and cs_item_sk=cs_item_sk and cs_customer_sk=ss_customer_sk)
 where coalesce(ws_qty,0)>0 and coalesce(cs_qty, 0)>0 and ss_sold_year=2000
 order by 
   ss_sold_year, ss_item_sk, ss_customer_sk,

+ 2 - 2
sample-queries-tpcds/query79.sql

@@ -1,6 +1,6 @@
 -- start query 1 in stream 0 using template query79.tpl and seed 2031708268
 select 
-  c_last_name,c_first_name,substr(s_city,1,30) ss,ss_ticket_number,amt,profit
+  c_last_name,c_first_name,substr(s_city,1,30),ss_ticket_number,amt,profit
   from
    (select ss_ticket_number
           ,ss_customer_sk
@@ -17,7 +17,7 @@ select
     and store.s_number_employees between 200 and 295
     group by ss_ticket_number,ss_customer_sk,ss_addr_sk,store.s_city) ms,customer
     where ss_customer_sk = c_customer_sk
- order by c_last_name,c_first_name,ss, profit
+ order by c_last_name,c_first_name,substr(s_city,1,30), profit
 limit 100;
 
 -- end query 1 in stream 0 using template query79.tpl

+ 3 - 3
sample-queries-tpcds/query80.sql

@@ -12,7 +12,7 @@ with ssr as
      promotion
  where ss_sold_date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date) 
-                  and (cast('1998-08-04' as date) +  interval '30' days)
+                  and (cast('1998-08-04' as date) +  30 days)
        and ss_store_sk = s_store_sk
        and ss_item_sk = i_item_sk
        and i_current_price > 50
@@ -33,7 +33,7 @@ with ssr as
      promotion
  where cs_sold_date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date)
-                  and (cast('1998-08-04' as date) +  interval '30' days)
+                  and (cast('1998-08-04' as date) +  30 days)
         and cs_catalog_page_sk = cp_catalog_page_sk
        and cs_item_sk = i_item_sk
        and i_current_price > 50
@@ -54,7 +54,7 @@ group by cp_catalog_page_id)
      promotion
  where ws_sold_date_sk = d_date_sk
        and d_date between cast('1998-08-04' as date)
-                  and (cast('1998-08-04' as date) +  interval '30' days)
+                  and (cast('1998-08-04' as date) +  30 days)
         and ws_web_site_sk = web_site_sk
        and ws_item_sk = i_item_sk
        and i_current_price > 50

+ 1 - 1
sample-queries-tpcds/query82.sql

@@ -6,7 +6,7 @@ select  i_item_id
  where i_current_price between 30 and 30+30
  and inv_item_sk = i_item_sk
  and d_date_sk=inv_date_sk
- and d_date between cast('2002-05-30' as date) and (cast('2002-05-30' as date) +  interval '60' days)
+ and d_date between cast('2002-05-30' as date) and (cast('2002-05-30' as date) +  60 days)
  and i_manufact_id in (437,129,727,663)
  and inv_quantity_on_hand between 100 and 500
  and ss_item_sk = i_item_sk

+ 1 - 1
sample-queries-tpcds/query84.sql

@@ -15,7 +15,7 @@ select  c_customer_id as customer_id
    and cd_demo_sk = c_current_cdemo_sk
    and hd_demo_sk = c_current_hdemo_sk
    and sr_cdemo_sk = cd_demo_sk
- order by customer_id
+ order by c_customer_id
  limit 100;
 
 -- end query 1 in stream 0 using template query84.tpl

+ 8 - 8
sample-queries-tpcds/query85.sql

@@ -1,8 +1,8 @@
 -- start query 1 in stream 0 using template query85.tpl and seed 622697896
-select  substr(r_reason_desc,1,20) ss
-       ,avg(ws_quantity) wq
-       ,avg(wr_refunded_cash) wr
-       ,avg(wr_fee) wf
+select  substr(r_reason_desc,1,20)
+       ,avg(ws_quantity)
+       ,avg(wr_refunded_cash)
+       ,avg(wr_fee)
  from web_sales, web_returns, web_page, customer_demographics cd1,
       customer_demographics cd2, customer_address, date_dim, reason 
  where ws_web_page_sk = wp_web_page_sk
@@ -75,10 +75,10 @@ select  substr(r_reason_desc,1,20) ss
     )
    )
 group by r_reason_desc
-order by ss
-        ,wq
-        ,wr
-        ,wf
+order by substr(r_reason_desc,1,20)
+        ,avg(ws_quantity)
+        ,avg(wr_refunded_cash)
+        ,avg(wr_fee)
 limit 100;
 
 -- end query 1 in stream 0 using template query85.tpl

+ 1 - 1
sample-queries-tpcds/query91.sql

@@ -26,6 +26,6 @@ and     ( (cd_marital_status       = 'M' and cd_education_status     = 'Unknown'
 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;
+order by sum(cr_net_loss) desc;
 
 -- end query 1 in stream 0 using template query91.tpl

+ 4 - 4
sample-queries-tpcds/query92.sql

@@ -1,6 +1,6 @@
 -- start query 1 in stream 0 using template query92.tpl and seed 2031708268
 select  
-   sum(ws_ext_discount_amt)  as `Excess Discount Amount`
+   sum(ws_ext_discount_amt)  as "Excess Discount Amount" 
 from 
     web_sales 
    ,item 
@@ -9,7 +9,7 @@ where
 i_manufact_id = 269
 and i_item_sk = ws_item_sk 
 and d_date between '1998-03-18' and 
-        (cast('1998-03-18' as date) + interval '90' days)
+        (cast('1998-03-18' as date) + 90 days)
 and d_date_sk = ws_sold_date_sk 
 and ws_ext_discount_amt  
      > ( 
@@ -21,10 +21,10 @@ and ws_ext_discount_amt
          WHERE 
               ws_item_sk = i_item_sk 
           and d_date between '1998-03-18' and
-                             (cast('1998-03-18' as date) + interval '90' days)
+                             (cast('1998-03-18' as date) + 90 days)
           and d_date_sk = ws_sold_date_sk 
       ) 
-order by `Excess Discount Amount`
+order by sum(ws_ext_discount_amt)
 limit 100;
 
 -- end query 1 in stream 0 using template query92.tpl

+ 5 - 5
sample-queries-tpcds/query94.sql

@@ -1,8 +1,8 @@
 -- start query 1 in stream 0 using template query94.tpl and seed 2031708268
 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`
+   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
   ,date_dim
@@ -10,7 +10,7 @@ from
   ,web_site
 where
     d_date between '1999-5-01' and 
-           (cast('1999-5-01' as date) + interval '60' days)
+           (cast('1999-5-01' as date) + 60 days)
 and ws1.ws_ship_date_sk = d_date_sk
 and ws1.ws_ship_addr_sk = ca_address_sk
 and ca_state = 'TX'
@@ -23,7 +23,7 @@ and exists (select *
 and not exists(select *
                from web_returns wr1
                where ws1.ws_order_number = wr1.wr_order_number)
-order by `order count`
+order by count(distinct ws_order_number)
 limit 100;
 
 -- end query 1 in stream 0 using template query94.tpl

+ 5 - 5
sample-queries-tpcds/query95.sql

@@ -5,9 +5,9 @@ with ws_wh as
  where ws1.ws_order_number = ws2.ws_order_number
    and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk)
  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`
+   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
   ,date_dim
@@ -15,7 +15,7 @@ from
   ,web_site
 where
     d_date between '1999-5-01' and 
-           (cast('1999-5-01' as date) + interval '60' days)
+           (cast('1999-5-01' as date) + 60 days)
 and ws1.ws_ship_date_sk = d_date_sk
 and ws1.ws_ship_addr_sk = ca_address_sk
 and ca_state = 'TX'
@@ -26,7 +26,7 @@ and ws1.ws_order_number in (select ws_order_number
 and ws1.ws_order_number in (select wr_order_number
                             from web_returns,ws_wh
                             where wr_order_number = ws_wh.ws_order_number)
-order by `order count`
+order by count(distinct ws_order_number)
 limit 100;
 
 -- end query 1 in stream 0 using template query95.tpl

+ 2 - 2
sample-queries-tpcds/query96.sql

@@ -1,5 +1,5 @@
 -- start query 1 in stream 0 using template query96.tpl and seed 1819994127
-select  count(*) cs
+select  count(*) 
 from store_sales
     ,household_demographics 
     ,time_dim, store
@@ -10,7 +10,7 @@ where ss_sold_time_sk = time_dim.t_time_sk
     and time_dim.t_minute >= 30
     and household_demographics.hd_dep_count = 5
     and store.s_store_name = 'ese'
-order by cs
+order by count(*)
 limit 100;
 
 -- end query 1 in stream 0 using template query96.tpl

+ 1 - 2
sample-queries-tpcds/query98.sql

@@ -3,7 +3,6 @@ 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
@@ -16,7 +15,7 @@ where
   	and i_category in ('Jewelry', 'Sports', 'Books')
   	and ss_sold_date_sk = d_date_sk
 	and d_date between cast('2001-01-12' as date) 
-				and (cast('2001-01-12' as date) + interval '30' days)
+				and (cast('2001-01-12' as date) + 30 days)
 group by 
 	i_item_id
         ,i_item_desc 

+ 2 - 2
sample-queries-tpcds/query99.sql

@@ -1,6 +1,6 @@
 -- start query 1 in stream 0 using template query99.tpl and seed 1819994127
 select  
-   substr(w_warehouse_name,1,20) ss
+   substr(w_warehouse_name,1,20) 
   ,sm_type
   ,cc_name
   ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end)  as `30 days`
@@ -27,7 +27,7 @@ group by
    substr(w_warehouse_name,1,20)
   ,sm_type
   ,cc_name
-order by ss
+order by substr(w_warehouse_name,1,20)
         ,sm_type
         ,cc_name
 limit 100;