From aa4a7dedfaf0626ef5db69ba2514da79d7a18874 Mon Sep 17 00:00:00 2001 From: perdelt Date: Thu, 14 Nov 2024 23:14:41 +0100 Subject: [PATCH] TPC-DS: Queries updated --- experiments/tpcds/queries-tpcds.config | 540 +++++++++++++++++++++++-- 1 file changed, 511 insertions(+), 29 deletions(-) diff --git a/experiments/tpcds/queries-tpcds.config b/experiments/tpcds/queries-tpcds.config index 3cb48f3a..b1ea7ea3 100644 --- a/experiments/tpcds/queries-tpcds.config +++ b/experiments/tpcds/queries-tpcds.config @@ -4759,7 +4759,7 @@ union all select * from ws) tmp1 group by i_manufact_id - order by total_sales + order by total_sales is not null, total_sales limit 100""", 'parameter': { @@ -4990,6 +4990,7 @@ group by i_category,i_class with rollup order by lochierarchy desc + ,case when lochierarchy = 0 then i_category is not null end ,case when lochierarchy = 0 then i_category end ,rank_within_parent limit 100""", @@ -5005,23 +5006,28 @@ CASE WHEN i_class IS NOT NULL THEN i_category END ORDER BY gross_margin ASC ) AS rank_within_parent - FROM ( - SELECT - i_category, - i_class, - SUM(ss_net_profit) / SUM(ss_ext_sales_price) AS gross_margin, - CASE WHEN i_category IS NULL THEN 1 ELSE 0 END + - CASE WHEN i_class IS NULL THEN 1 ELSE 0 END AS lochierarchy - FROM - store_sales - JOIN date_dim AS d1 ON d1.d_date_sk = ss_sold_date_sk - JOIN item ON i_item_sk = ss_item_sk - JOIN store ON s_store_sk = ss_store_sk - WHERE - d1.d_year = {YEAR} - AND s_state IN ('{STATE1}', '{STATE2}', '{STATE3}', '{STATE4}', '{STATE5}', '{STATE6}', '{STATE7}', '{STATE8}') - GROUP BY i_category, i_class WITH ROLLUP - ) AS summary + FROM ( + SELECT + i_category, + i_class, + SUM(ss_net_profit) / SUM(ss_ext_sales_price) AS gross_margin, + CASE WHEN i_category IS NULL THEN 1 ELSE 0 END + + CASE WHEN i_class IS NULL THEN 1 ELSE 0 END AS lochierarchy + FROM + store_sales + JOIN date_dim AS d1 ON d1.d_date_sk = ss_sold_date_sk + JOIN item ON i_item_sk = ss_item_sk + JOIN store ON s_store_sk = ss_store_sk + WHERE + d1.d_year = {YEAR} + AND s_state IN ('{STATE1}', '{STATE2}', '{STATE3}', '{STATE4}', '{STATE5}', '{STATE6}', '{STATE7}', '{STATE8}') + GROUP BY i_category, i_class WITH ROLLUP + ) AS summary + order by + lochierarchy is not null, lochierarchy desc + ,case when lochierarchy = 0 then i_category is not null end + ,case when lochierarchy = 0 then i_category end + ,rank_within_parent LIMIT 100""", 'MonetDB': """select * FROM ( @@ -5048,7 +5054,8 @@ group by rollup(i_category,i_class) ) tmp order by - lochierarchy desc + lochierarchy is not null, lochierarchy desc + ,case when lochierarchy = 0 then i_category is not null end ,case when lochierarchy = 0 then i_category end ,rank_within_parent limit 100""", @@ -5074,7 +5081,8 @@ and s_state in ('{STATE1}','{STATE2}','{STATE3}','{STATE4}','{STATE5}','{STATE6}','{STATE7}','{STATE8}') group by rollup(i_category,i_class) order by - grouping(i_category)+grouping(i_class) desc + grouping(i_category)+grouping(i_class) is not null, grouping(i_category)+grouping(i_class) desc + ,case when grouping(i_category)+grouping(i_class) = 0 then i_category is not null end ,case when grouping(i_category)+grouping(i_class) = 0 then i_category end ,rank_within_parent limit 100""" @@ -7477,7 +7485,7 @@ LIMIT 100""" sc.revenue <= 0.1 * sb.ave and s_store_sk = sc.ss_store_sk and i_item_sk = sc.ss_item_sk - order by s_store_name, i_item_desc + order by s_store_name is not null, s_store_name, i_item_desc is not null, i_item_desc limit 100""", 'parameter': { @@ -7561,7 +7569,7 @@ LIMIT 100""" ,w_county ,w_state ,w_country - ,'{SMC1}' || ',' || '{SMC2}' as ship_carriers + ,CONCAT('{SMC1}' , ',' , '{SMC2}') as ship_carriers ,d_year as years ,sum(case when d_moy = 1 then {SALESONE}* ws_quantity else 0 end) as jan_sales @@ -7641,7 +7649,7 @@ LIMIT 100""" ,w_county ,w_state ,w_country - ,'{SMC1}' || ',' || '{SMC2}' as ship_carriers + ,CONCAT('{SMC1}', ',', '{SMC2}') as ship_carriers ,d_year as years ,sum(case when d_moy = 1 then {SALESTWO}* cs_quantity else 0 end) as jan_sales @@ -7725,6 +7733,442 @@ LIMIT 100""" ,years order by w_warehouse_name limit 100""", + 'DBMS': { + 'MonetDB': """ select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,years + ,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 + ,'{SMC1}' || ',' || '{SMC2}' as ship_carriers + ,d_year as years + ,sum(case when d_moy = 1 + then {SALESONE}* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then {SALESONE}* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then {SALESONE}* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then {SALESONE}* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then {SALESONE}* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then {SALESONE}* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then {SALESONE}* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then {SALESONE}* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then {SALESONE}* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then {SALESONE}* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then {SALESONE}* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then {SALESONE}* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then {NETONE} * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then {NETONE} * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then {NETONE} * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then {NETONE} * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then {NETONE} * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then {NETONE} * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then {NETONE} * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then {NETONE} * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then {NETONE} * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then {NETONE} * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then {NETONE} * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then {NETONE} * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = {YEAR} + and t_time between {TIMEONE} and {TIMEONE}+28800 + and sm_carrier in ('{SMC1}','{SMC2}') + 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('{SMC1}', ',', '{SMC2}') as ship_carriers + ,d_year as years + ,sum(case when d_moy = 1 + then {SALESTWO}* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then {SALESTWO}* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then {SALESTWO}* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then {SALESTWO}* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then {SALESTWO}* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then {SALESTWO}* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then {SALESTWO}* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then {SALESTWO}* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then {SALESTWO}* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then {SALESTWO}* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then {SALESTWO}* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then {SALESTWO}* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then {NETTWO} * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then {NETTWO} * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then {NETTWO} * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then {NETTWO} * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then {NETTWO} * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then {NETTWO} * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then {NETTWO} * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then {NETTWO} * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then {NETTWO} * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then {NETTWO} * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then {NETTWO} * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then {NETTWO} * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = {YEAR} + and t_time between {TIMEONE} AND {TIMEONE}+28800 + and sm_carrier in ('{SMC1}','{SMC2}') + 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 + ,years + order by w_warehouse_name + limit 100""", + 'PostgreSQL': """ select + w_warehouse_name + ,w_warehouse_sq_ft + ,w_city + ,w_county + ,w_state + ,w_country + ,ship_carriers + ,years + ,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 + ,'{SMC1}' || ',' || '{SMC2}' as ship_carriers + ,d_year as years + ,sum(case when d_moy = 1 + then {SALESONE}* ws_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then {SALESONE}* ws_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then {SALESONE}* ws_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then {SALESONE}* ws_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then {SALESONE}* ws_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then {SALESONE}* ws_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then {SALESONE}* ws_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then {SALESONE}* ws_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then {SALESONE}* ws_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then {SALESONE}* ws_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then {SALESONE}* ws_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then {SALESONE}* ws_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then {NETONE} * ws_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then {NETONE} * ws_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then {NETONE} * ws_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then {NETONE} * ws_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then {NETONE} * ws_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then {NETONE} * ws_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then {NETONE} * ws_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then {NETONE} * ws_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then {NETONE} * ws_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then {NETONE} * ws_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then {NETONE} * ws_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then {NETONE} * ws_quantity else 0 end) as dec_net + from + web_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + ws_warehouse_sk = w_warehouse_sk + and ws_sold_date_sk = d_date_sk + and ws_sold_time_sk = t_time_sk + and ws_ship_mode_sk = sm_ship_mode_sk + and d_year = {YEAR} + and t_time between {TIMEONE} and {TIMEONE}+28800 + and sm_carrier in ('{SMC1}','{SMC2}') + 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('{SMC1}', ',', '{SMC2}') as ship_carriers + ,d_year as years + ,sum(case when d_moy = 1 + then {SALESTWO}* cs_quantity else 0 end) as jan_sales + ,sum(case when d_moy = 2 + then {SALESTWO}* cs_quantity else 0 end) as feb_sales + ,sum(case when d_moy = 3 + then {SALESTWO}* cs_quantity else 0 end) as mar_sales + ,sum(case when d_moy = 4 + then {SALESTWO}* cs_quantity else 0 end) as apr_sales + ,sum(case when d_moy = 5 + then {SALESTWO}* cs_quantity else 0 end) as may_sales + ,sum(case when d_moy = 6 + then {SALESTWO}* cs_quantity else 0 end) as jun_sales + ,sum(case when d_moy = 7 + then {SALESTWO}* cs_quantity else 0 end) as jul_sales + ,sum(case when d_moy = 8 + then {SALESTWO}* cs_quantity else 0 end) as aug_sales + ,sum(case when d_moy = 9 + then {SALESTWO}* cs_quantity else 0 end) as sep_sales + ,sum(case when d_moy = 10 + then {SALESTWO}* cs_quantity else 0 end) as oct_sales + ,sum(case when d_moy = 11 + then {SALESTWO}* cs_quantity else 0 end) as nov_sales + ,sum(case when d_moy = 12 + then {SALESTWO}* cs_quantity else 0 end) as dec_sales + ,sum(case when d_moy = 1 + then {NETTWO} * cs_quantity else 0 end) as jan_net + ,sum(case when d_moy = 2 + then {NETTWO} * cs_quantity else 0 end) as feb_net + ,sum(case when d_moy = 3 + then {NETTWO} * cs_quantity else 0 end) as mar_net + ,sum(case when d_moy = 4 + then {NETTWO} * cs_quantity else 0 end) as apr_net + ,sum(case when d_moy = 5 + then {NETTWO} * cs_quantity else 0 end) as may_net + ,sum(case when d_moy = 6 + then {NETTWO} * cs_quantity else 0 end) as jun_net + ,sum(case when d_moy = 7 + then {NETTWO} * cs_quantity else 0 end) as jul_net + ,sum(case when d_moy = 8 + then {NETTWO} * cs_quantity else 0 end) as aug_net + ,sum(case when d_moy = 9 + then {NETTWO} * cs_quantity else 0 end) as sep_net + ,sum(case when d_moy = 10 + then {NETTWO} * cs_quantity else 0 end) as oct_net + ,sum(case when d_moy = 11 + then {NETTWO} * cs_quantity else 0 end) as nov_net + ,sum(case when d_moy = 12 + then {NETTWO} * cs_quantity else 0 end) as dec_net + from + catalog_sales + ,warehouse + ,date_dim + ,time_dim + ,ship_mode + where + cs_warehouse_sk = w_warehouse_sk + and cs_sold_date_sk = d_date_sk + and cs_sold_time_sk = t_time_sk + and cs_ship_mode_sk = sm_ship_mode_sk + and d_year = {YEAR} + and t_time between {TIMEONE} AND {TIMEONE}+28800 + and sm_carrier in ('{SMC1}','{SMC2}') + 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 + ,years + order by w_warehouse_name + limit 100""", + }, 'parameter': { 'NETONE': { @@ -8106,7 +8550,7 @@ LIMIT 100""" ,rank() over ( partition by grouping(s_state)+grouping(s_county), case when grouping(s_county) = 0 then s_state end - order by sum(ss_net_profit) desc) as rank_within_parent + order by sum(ss_net_profit) is not null, sum(ss_net_profit) desc) as rank_within_parent from store_sales ,date_dim d1 @@ -8142,7 +8586,7 @@ SELECT 0 AS lochierarchy, -- Indicates detailed level RANK() OVER ( PARTITION BY s_state - ORDER BY SUM(ss_net_profit) DESC + ORDER BY SUM(ss_net_profit) is not null, SUM(ss_net_profit) DESC ) AS rank_within_parent FROM store_sales @@ -8175,7 +8619,7 @@ SELECT 1 AS lochierarchy, -- Indicates subtotal level RANK() OVER ( PARTITION BY s_state - ORDER BY SUM(ss_net_profit) DESC + ORDER BY SUM(ss_net_profit) is not null, SUM(ss_net_profit) DESC ) AS rank_within_parent FROM store_sales @@ -8239,7 +8683,7 @@ LIMIT 100""", ,rank() over ( partition by grouping(s_state)+grouping(s_county), case when grouping(s_county) = 0 then s_state end - order by sum(ss_net_profit) desc) as rank_within_parent + order by sum(ss_net_profit) desc) is not null, sum(ss_net_profit) desc) as rank_within_parent from store_sales ,date_dim d1 @@ -8349,7 +8793,7 @@ FROM ( CASE WHEN s_state IS NULL THEN 1 ELSE 0 END + CASE WHEN s_county IS NULL THEN 1 ELSE 0 END, CASE WHEN s_county IS NOT NULL THEN s_state END - ORDER BY SUM(ss_net_profit) DESC + ORDER BY SUM(ss_net_profit) is not null, SUM(ss_net_profit) DESC ) AS rank_within_parent FROM store_sales @@ -10502,7 +10946,7 @@ LIMIT 100""" { 'title': "TPC-DS Q84", 'query': """ select c_customer_id as customer_id - , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + , CONCAT(coalesce(c_last_name,'') , ', ' , coalesce(c_first_name,'')) as customername from customer ,customer_address ,customer_demographics @@ -10519,6 +10963,44 @@ LIMIT 100""" and sr_cdemo_sk = cd_demo_sk order by c_customer_id limit 100""", + 'DBMS': { + 'MonetDB': """ select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = '{CITY}' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= {INCOME} + and ib_upper_bound <= {INCOME} + 50000 + and ib_income_band_sk = hd_income_band_sk + 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 c_customer_id + limit 100""", + 'PostgreSQL': """ select c_customer_id as customer_id + , coalesce(c_last_name,'') || ', ' || coalesce(c_first_name,'') as customername + from customer + ,customer_address + ,customer_demographics + ,household_demographics + ,income_band + ,store_returns + where ca_city = '{CITY}' + and c_current_addr_sk = ca_address_sk + and ib_lower_bound >= {INCOME} + and ib_upper_bound <= {INCOME} + 50000 + and ib_income_band_sk = hd_income_band_sk + 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 c_customer_id + limit 100""", + }, 'parameter': { 'CITY': {