diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q01.sql b/ydb/library/benchmarks/queries/tpcds/pg/q01.sql index 0a7d86849d2d..a61238862998 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q01.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q01.sql @@ -18,7 +18,7 @@ where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2::numeric from customer_total_return ctr2 where ctr1.ctr_store_sk = ctr2.ctr_store_sk) and s_store_sk = ctr1.ctr_store_sk -and s_state = 'TN' +and s_state = 'NM' and ctr1.ctr_customer_sk = c_customer_sk order by c_customer_id limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q02.sql b/ydb/library/benchmarks/queries/tpcds/pg/q02.sql index e4a875745173..1146d4bbba1b 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q02.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q02.sql @@ -5,12 +5,12 @@ with wscs as ,sales_price from (select ws_sold_date_sk sold_date_sk ,ws_ext_sales_price sales_price - from {{web_sales}} + from {{web_sales}} union all select cs_sold_date_sk sold_date_sk ,cs_ext_sales_price sales_price from {{catalog_sales}}) a), - wswscs as + wswscs as (select d_week_seq, sum(case when (d_day_name='Sunday') then sales_price else null::numeric end) sun_sales, sum(case when (d_day_name='Monday') then sales_price else null::numeric end) mon_sales, @@ -40,9 +40,9 @@ with wscs as ,thu_sales thu_sales1 ,fri_sales fri_sales1 ,sat_sales sat_sales1 - from wswscs,{{date_dim}} + from wswscs,{{date_dim}} where date_dim.d_week_seq = wswscs.d_week_seq and - d_year = 2001) y, + d_year = 1998) y, (select wswscs.d_week_seq d_week_seq2 ,sun_sales sun_sales2 ,mon_sales mon_sales2 @@ -52,9 +52,9 @@ with wscs as ,fri_sales fri_sales2 ,sat_sales sat_sales2 from wswscs - ,{{date_dim}} + ,{{date_dim}} where date_dim.d_week_seq = wswscs.d_week_seq and - d_year = 2001+1) z + d_year = 1998+1) z where d_week_seq1=d_week_seq2-53 order by d_week_seq1; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q03.sql b/ydb/library/benchmarks/queries/tpcds/pg/q03.sql index b1613c11bc3d..5114ec8c2eda 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q03.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q03.sql @@ -1,16 +1,16 @@ {% include 'header.sql.jinja' %} -select dt.d_year - ,item.i_brand_id brand_id +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 + 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 item.i_manufact_id = 816 + and dt.d_moy=11 group by dt.d_year ,item.i_brand ,item.i_brand_id diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q04.sql b/ydb/library/benchmarks/queries/tpcds/pg/q04.sql index 715ca182e292..30e11709e063 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q04.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q04.sql @@ -73,7 +73,7 @@ union all ,c_email_address ,d_year ) - select + select t_s_secyear.customer_id ,t_s_secyear.customer_first_name ,t_s_secyear.customer_last_name @@ -95,12 +95,12 @@ union all and t_s_secyear.sale_type = 's' and t_c_secyear.sale_type = 'c' and t_w_secyear.sale_type = 'w' - and t_s_firstyear.dyear = 2001 - and t_s_secyear.dyear = 2001+1 - and t_c_firstyear.dyear = 2001 - and t_c_secyear.dyear = 2001+1 - and t_w_firstyear.dyear = 2001 - and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_c_firstyear.dyear = 1999 + and t_c_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 and t_s_firstyear.year_total > 0::numeric and t_c_firstyear.year_total > 0::numeric and t_w_firstyear.year_total > 0::numeric diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q05.sql b/ydb/library/benchmarks/queries/tpcds/pg/q05.sql index 3cf91eb69222..75de0465d888 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q05.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q05.sql @@ -26,8 +26,8 @@ with ssr as {{date_dim}}, {{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' day)::date + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + interval '14' day)::date and store_sk = s_store_sk group by s_store_id) , @@ -57,8 +57,8 @@ with ssr as {{date_dim}}, {{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' day)::date + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + interval '14' day)::date and page_sk = cp_catalog_page_sk group by cp_catalog_page_id) , @@ -90,8 +90,8 @@ with ssr as {{date_dim}}, {{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' day)::date + and d_date between cast('2000-08-19' as date) + and (cast('2000-08-19' as date) + interval '14' day)::date and wsr_web_site_sk = web_site_sk group by web_site_id) select channel @@ -99,7 +99,7 @@ with ssr as , sum(sales) as sales , sum(returns) as returns , sum(profit) as profit - from + from (select 'store channel' as channel , 'store' || s_store_id as id , sales diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q06.sql b/ydb/library/benchmarks/queries/tpcds/pg/q06.sql index 2a8838181f0e..c973bac20473 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q06.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q06.sql @@ -10,18 +10,18 @@ select a.ca_state state, count(*) cnt and c.c_customer_sk = s.ss_customer_sk and s.ss_sold_date_sk = d.d_date_sk and s.ss_item_sk = i.i_item_sk - and d.d_month_seq = + and d.d_month_seq = (select distinct (d_month_seq) from {{date_dim}} - where d_year = 2000 - and d_moy = 2 ) - and i.i_current_price > 1.2::numeric * - (select avg(j.i_current_price) - from {{item}} j + where d_year = 2002 + and d_moy = 3 ) + and i.i_current_price > 1.2::numeric * + (select avg(j.i_current_price) + from {{item}} j where j.i_category = i.i_category) group by a.ca_state having count(*) >= 10 - order by cnt, a.ca_state + order by cnt, a.ca_state limit 100; -- end query 1 in stream 0 using template ../query_templates/query6.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q07.sql b/ydb/library/benchmarks/queries/tpcds/pg/q07.sql index 475c0c4845fa..990977cffae5 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q07.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q07.sql @@ -1,20 +1,20 @@ {% include 'header.sql.jinja' %} -select i_item_id, +select i_item_id, avg(ss_quantity) agg1, avg(ss_list_price) agg2, avg(ss_coupon_amt) agg3, - avg(ss_sales_price) agg4 + avg(ss_sales_price) agg4 from {{store_sales}}, {{customer_demographics}}, {{date_dim}}, {{item}}, {{promotion}} where ss_sold_date_sk = d_date_sk and ss_item_sk = i_item_sk and ss_cdemo_sk = cd_demo_sk and ss_promo_sk = p_promo_sk and - cd_gender = 'F' and + cd_gender = 'F' and cd_marital_status = 'W' and - cd_education_status = 'Primary' and + cd_education_status = 'College' and (p_channel_email = 'N' or p_channel_event = 'N') and - d_year = 1998 + d_year = 2001 group by i_item_id order by i_item_id limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q08.sql b/ydb/library/benchmarks/queries/tpcds/pg/q08.sql index ccfa35d2a92b..220c40fc23f8 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q08.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q08.sql @@ -10,86 +10,86 @@ select s_store_name SELECT substr(ca_zip,1,5) ca_zip FROM {{customer_address}} WHERE substr(ca_zip,1,5) IN ( - '89436','30868','65085','22977','83927','77557', - '58429','40697','80614','10502','32779', - '91137','61265','98294','17921','18427', - '21203','59362','87291','84093','21505', - '17184','10866','67898','25797','28055', - '18377','80332','74535','21757','29742', - '90885','29898','17819','40811','25990', - '47513','89531','91068','10391','18846', - '99223','82637','41368','83658','86199', - '81625','26696','89338','88425','32200', - '81427','19053','77471','36610','99823', - '43276','41249','48584','83550','82276', - '18842','78890','14090','38123','40936', - '34425','19850','43286','80072','79188', - '54191','11395','50497','84861','90733', - '21068','57666','37119','25004','57835', - '70067','62878','95806','19303','18840', - '19124','29785','16737','16022','49613', - '89977','68310','60069','98360','48649', - '39050','41793','25002','27413','39736', - '47208','16515','94808','57648','15009', - '80015','42961','63982','21744','71853', - '81087','67468','34175','64008','20261', - '11201','51799','48043','45645','61163', - '48375','36447','57042','21218','41100', - '89951','22745','35851','83326','61125', - '78298','80752','49858','52940','96976', - '63792','11376','53582','18717','90226', - '50530','94203','99447','27670','96577', - '57856','56372','16165','23427','54561', - '28806','44439','22926','30123','61451', - '92397','56979','92309','70873','13355', - '21801','46346','37562','56458','28286', - '47306','99555','69399','26234','47546', - '49661','88601','35943','39936','25632', - '24611','44166','56648','30379','59785', - '11110','14329','93815','52226','71381', - '13842','25612','63294','14664','21077', - '82626','18799','60915','81020','56447', - '76619','11433','13414','42548','92713', - '70467','30884','47484','16072','38936', - '13036','88376','45539','35901','19506', - '65690','73957','71850','49231','14276', - '20005','18384','76615','11635','38177', - '55607','41369','95447','58581','58149', - '91946','33790','76232','75692','95464', - '22246','51061','56692','53121','77209', - '15482','10688','14868','45907','73520', - '72666','25734','17959','24677','66446', - '94627','53535','15560','41967','69297', - '11929','59403','33283','52232','57350', - '43933','40921','36635','10827','71286', - '19736','80619','25251','95042','15526', - '36496','55854','49124','81980','35375', - '49157','63512','28944','14946','36503', - '54010','18767','23969','43905','66979', - '33113','21286','58471','59080','13395', - '79144','70373','67031','38360','26705', - '50906','52406','26066','73146','15884', - '31897','30045','61068','45550','92454', - '13376','14354','19770','22928','97790', - '50723','46081','30202','14410','20223', - '88500','67298','13261','14172','81410', - '93578','83583','46047','94167','82564', - '21156','15799','86709','37931','74703', - '83103','23054','70470','72008','49247', - '91911','69998','20961','70070','63197', - '54853','88191','91830','49521','19454', - '81450','89091','62378','25683','61869', - '51744','36580','85778','36871','48121', - '28810','83712','45486','67393','26935', - '42393','20132','55349','86057','21309', - '80218','10094','11357','48819','39734', - '40758','30432','21204','29467','30214', - '61024','55307','74621','11622','68908', - '33032','52868','99194','99900','84936', - '69036','99149','45013','32895','59004', - '32322','14933','32936','33562','72550', - '27385','58049','58200','16808','21360', - '32961','18586','79307','15492') + '47602','16704','35863','28577','83910','36201', + '58412','48162','28055','41419','80332', + '38607','77817','24891','16226','18410', + '21231','59345','13918','51089','20317', + '17167','54585','67881','78366','47770', + '18360','51717','73108','14440','21800', + '89338','45859','65501','34948','25973', + '73219','25333','17291','10374','18829', + '60736','82620','41351','52094','19326', + '25214','54207','40936','21814','79077', + '25178','75742','77454','30621','89193', + '27369','41232','48567','83041','71948', + '37119','68341','14073','16891','62878', + '49130','19833','24286','27700','40979', + '50412','81504','94835','84844','71954', + '39503','57649','18434','24987','12350', + '86379','27413','44529','98569','16515', + '27287','24255','21094','16005','56436', + '91110','68293','56455','54558','10298', + '83647','32754','27052','51766','19444', + '13869','45645','94791','57631','20712', + '37788','41807','46507','21727','71836', + '81070','50632','88086','63991','20244', + '31655','51782','29818','63792','68605', + '94898','36430','57025','20601','82080', + '33869','22728','35834','29086','92645', + '98584','98072','11652','78093','57553', + '43830','71144','53565','18700','90209', + '71256','38353','54364','28571','96560', + '57839','56355','50679','45266','84680', + '34306','34972','48530','30106','15371', + '92380','84247','92292','68852','13338', + '34594','82602','70073','98069','85066', + '47289','11686','98862','26217','47529', + '63294','51793','35926','24227','14196', + '24594','32489','99060','49472','43432', + '49211','14312','88137','47369','56877', + '20534','81755','15794','12318','21060', + '73134','41255','63073','81003','73873', + '66057','51184','51195','45676','92696', + '70450','90669','98338','25264','38919', + '59226','58581','60298','17895','19489', + '52301','80846','95464','68770','51634', + '19988','18367','18421','11618','67975', + '25494','41352','95430','15734','62585', + '97173','33773','10425','75675','53535', + '17879','41967','12197','67998','79658', + '59130','72592','14851','43933','68101', + '50636','25717','71286','24660','58058', + '72991','95042','15543','33122','69280', + '11912','59386','27642','65177','17672', + '33467','64592','36335','54010','18767', + '63193','42361','49254','33113','33159', + '36479','59080','11855','81963','31016', + '49140','29392','41836','32958','53163', + '13844','73146','23952','65148','93498', + '14530','46131','58454','13376','13378', + '83986','12320','17193','59852','46081', + '98533','52389','13086','68843','31013', + '13261','60560','13443','45533','83583', + '11489','58218','19753','22911','25115', + '86709','27156','32669','13123','51933', + '39214','41331','66943','14155','69998', + '49101','70070','35076','14242','73021', + '59494','15782','29752','37914','74686', + '83086','34473','15751','81084','49230', + '91894','60624','17819','28810','63180', + '56224','39459','55233','75752','43639', + '55349','86057','62361','50788','31830', + '58062','18218','85761','60083','45484', + '21204','90229','70041','41162','35390', + '16364','39500','68908','26689','52868', + '81335','40146','11340','61527','61794', + '71997','30415','59004','29450','58117', + '69952','33562','83833','27385','61860', + '96435','48333','23065','32961','84919', + '61997','99132','22815','56600','68730', + '48017','95694','32919','88217','27116', + '28239','58032','18884','16791','21343', + '97462','18569','75660','15475') intersect select ca_zip from (SELECT substr(ca_zip,1,5) ca_zip,count(*) cnt @@ -100,7 +100,7 @@ select s_store_name having count(*) > 10)A1)A2) V1 where ss_store_sk = s_store_sk and ss_sold_date_sk = d_date_sk - and d_qoy = 1 and d_year = 2002 + and d_qoy = 2 and d_year = 1998 and (substr(s_zip,1,2) = substr(V1.ca_zip,1,2)) group by s_store_name order by s_store_name diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q09.sql b/ydb/library/benchmarks/queries/tpcds/pg/q09.sql index 85e42f586470..235dd0d4b6b9 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q09.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q09.sql @@ -1,26 +1,26 @@ {% include 'header.sql.jinja' %} -select case when (select count(*) - from {{store_sales}} - where ss_quantity between 1 and 20) > 25437 - then (select avg(ss_ext_discount_amt) - from {{store_sales}} - where ss_quantity between 1 and 20) +select case when (select count(*) + from {{store_sales}} + where ss_quantity between 1 and 20) > 98972190 + then (select avg(ss_ext_discount_amt) + from {{store_sales}} + where ss_quantity between 1 and 20) else (select avg(ss_net_profit) from {{store_sales}} where ss_quantity between 1 and 20) end bucket1 , case when (select count(*) from {{store_sales}} - where ss_quantity between 21 and 40) > 22746 + where ss_quantity between 21 and 40) > 160856845 then (select avg(ss_ext_discount_amt) from {{store_sales}} - where ss_quantity between 21 and 40) + where ss_quantity between 21 and 40) else (select avg(ss_net_profit) from {{store_sales}} where ss_quantity between 21 and 40) end bucket2, case when (select count(*) from {{store_sales}} - where ss_quantity between 41 and 60) > 9387 + where ss_quantity between 41 and 60) > 12733327 then (select avg(ss_ext_discount_amt) from {{store_sales}} where ss_quantity between 41 and 60) @@ -29,7 +29,7 @@ select case when (select count(*) where ss_quantity between 41 and 60) end bucket3, case when (select count(*) from {{store_sales}} - where ss_quantity between 61 and 80) > 10098 + where ss_quantity between 61 and 80) > 96251173 then (select avg(ss_ext_discount_amt) from {{store_sales}} where ss_quantity between 61 and 80) @@ -38,7 +38,7 @@ select case when (select count(*) where ss_quantity between 61 and 80) end bucket4, case when (select count(*) from {{store_sales}} - where ss_quantity between 81 and 100) > 18213 + where ss_quantity between 81 and 100) > 80049606 then (select avg(ss_ext_discount_amt) from {{store_sales}} where ss_quantity between 81 and 100) diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q10.sql b/ydb/library/benchmarks/queries/tpcds/pg/q10.sql index a0a140fc42a1..8163409f7124 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q10.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q10.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -select +select cd_gender, cd_marital_status, cd_education_status, @@ -19,26 +19,26 @@ select {{customer}} c,{{customer_address}} ca,{{customer_demographics}} where c.c_current_addr_sk = ca.ca_address_sk and - ca_county in ('Walker County','Richland County','Gaines County','Douglas County','Dona Ana County') and - cd_demo_sk = c.c_current_cdemo_sk and + ca_county in ('Fillmore County','McPherson County','Bonneville County','Boone County','Brown County') and + cd_demo_sk = c.c_current_cdemo_sk and exists (select * from {{store_sales}},{{date_dim}} where c.c_customer_sk = ss_customer_sk and ss_sold_date_sk = d_date_sk and - d_year = 2002 and - d_moy between 4 and 4+3) and + d_year = 2000 and + d_moy between 3 and 3+3) and (exists (select * from {{web_sales}},{{date_dim}} where c.c_customer_sk = ws_bill_customer_sk and ws_sold_date_sk = d_date_sk and - d_year = 2002 and - d_moy between 4 ANd 4+3) or - exists (select * + d_year = 2000 and + d_moy between 3 ANd 3+3) or + exists (select * from {{catalog_sales}},{{date_dim}} where c.c_customer_sk = cs_ship_customer_sk and cs_sold_date_sk = d_date_sk and - d_year = 2002 and - d_moy between 4 and 4+3)) + d_year = 2000 and + d_moy between 3 and 3+3)) group by cd_gender, cd_marital_status, cd_education_status, diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q11.sql b/ydb/library/benchmarks/queries/tpcds/pg/q11.sql index 9de34259a8d6..fb91161f085a 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q11.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q11.sql @@ -19,11 +19,11 @@ with year_total as ( group by c_customer_id ,c_first_name ,c_last_name - ,c_preferred_cust_flag + ,c_preferred_cust_flag ,c_birth_country ,c_login ,c_email_address - ,d_year + ,d_year union all select c_customer_id customer_id ,c_first_name customer_first_name @@ -43,13 +43,13 @@ with year_total as ( group by c_customer_id ,c_first_name ,c_last_name - ,c_preferred_cust_flag + ,c_preferred_cust_flag ,c_birth_country ,c_login ,c_email_address ,d_year ) - select + select t_s_secyear.customer_id ,t_s_secyear.customer_first_name ,t_s_secyear.customer_last_name @@ -65,10 +65,10 @@ with year_total as ( and t_w_firstyear.sale_type = 'w' and t_s_secyear.sale_type = 's' and t_w_secyear.sale_type = 'w' - and t_s_firstyear.dyear = 2001 - and t_s_secyear.dyear = 2001+1 - and t_w_firstyear.dyear = 2001 - and t_w_secyear.dyear = 2001+1 + and t_s_firstyear.dyear = 1999 + and t_s_secyear.dyear = 1999+1 + and t_w_firstyear.dyear = 1999 + and t_w_secyear.dyear = 1999+1 and t_s_firstyear.year_total > 0::numeric and t_w_firstyear.year_total > 0::numeric and case when t_w_firstyear.year_total > 0::numeric then t_w_secyear.year_total / t_w_firstyear.year_total else 0.0::numeric end diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q12.sql b/ydb/library/benchmarks/queries/tpcds/pg/q12.sql index ce190de71c51..802634ab6399 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q12.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q12.sql @@ -1,30 +1,30 @@ {% include 'header.sql.jinja' %} select i_item_id - ,i_item_desc - ,i_category - ,i_class + ,i_item_desc + ,i_category + ,i_class ,i_current_price - ,sum(ws_ext_sales_price) as itemrevenue + ,sum(ws_ext_sales_price) as itemrevenue ,sum(ws_ext_sales_price)*100::numeric/sum(sum(ws_ext_sales_price)) over (partition by i_class) as revenueratio -from +from {{web_sales}} - ,{{item}} + ,{{item}} ,{{date_dim}} -where - ws_item_sk = i_item_sk - and i_category in ('Jewelry', 'Sports', 'Books') +where + ws_item_sk = i_item_sk + and i_category in ('Electronics', 'Books', 'Women') 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' day)::date -group by + and d_date between cast('1998-01-06' as date) + and (cast('1998-01-06' as date) + interval '30' day)::date +group by i_item_id - ,i_item_desc + ,i_item_desc ,i_category ,i_class ,i_current_price -order by +order by i_category ,i_class ,i_item_id diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q13.sql b/ydb/library/benchmarks/queries/tpcds/pg/q13.sql index 189162823bb7..4b959376ef58 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q13.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q13.sql @@ -14,38 +14,38 @@ select avg(ss_quantity) and ss_sold_date_sk = d_date_sk and d_year = 2001 and((ss_hdemo_sk=hd_demo_sk and cd_demo_sk = ss_cdemo_sk - and cd_marital_status = 'D' - and cd_education_status = '2 yr Degree' + and cd_marital_status = 'U' + and cd_education_status = 'Secondary' and ss_sales_price between 100.00::numeric and 150.00::numeric - and hd_dep_count = 3 + and hd_dep_count = 3 )or (ss_hdemo_sk=hd_demo_sk and cd_demo_sk = ss_cdemo_sk - and cd_marital_status = 'S' - and cd_education_status = 'Secondary' - and ss_sales_price between 50.00::numeric and 100.00::numeric + and cd_marital_status = 'W' + and cd_education_status = 'College' + and ss_sales_price between 50.00::numeric and 100.00::numeric and hd_dep_count = 1 - ) or + ) or (ss_hdemo_sk=hd_demo_sk and cd_demo_sk = ss_cdemo_sk - and cd_marital_status = 'W' - and cd_education_status = 'Advanced Degree' - and ss_sales_price between 150.00::numeric and 200.00::numeric - and hd_dep_count = 1 + and cd_marital_status = 'D' + and cd_education_status = 'Primary' + and ss_sales_price between 150.00::numeric and 200.00::numeric + and hd_dep_count = 1 )) and((ss_addr_sk = ca_address_sk and ca_country = 'United States' - and ca_state in ('CO', 'IL', 'MN') - and ss_net_profit between 100::numeric and 200::numeric + and ca_state in ('TX', 'OK', 'MI') + and ss_net_profit between 100::numeric and 200::numeric ) or (ss_addr_sk = ca_address_sk and ca_country = 'United States' - and ca_state in ('OH', 'MT', 'NM') - and ss_net_profit between 150::numeric and 300::numeric + and ca_state in ('WA', 'NC', 'OH') + and ss_net_profit between 150::numeric and 300::numeric ) or (ss_addr_sk = ca_address_sk and ca_country = 'United States' - and ca_state in ('TX', 'MO', 'MI') + and ca_state in ('MT', 'FL', 'GA') and ss_net_profit between 50::numeric and 250::numeric )) ; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q14.sql b/ydb/library/benchmarks/queries/tpcds/pg/q14.sql index c6a38034f5c7..ff56ff134a16 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q14.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q14.sql @@ -11,8 +11,8 @@ with cross_items as ,{{date_dim}} d1 where ss_item_sk = iss.i_item_sk and ss_sold_date_sk = d1.d_date_sk - and d1.d_year between 1998 AND 1998 + 2 - intersect + and d1.d_year between 2000 AND 2000 + 2 + intersect select ics.i_brand_id ,ics.i_class_id ,ics.i_category_id @@ -21,7 +21,7 @@ with cross_items as ,{{date_dim}} d2 where cs_item_sk = ics.i_item_sk and cs_sold_date_sk = d2.d_date_sk - and d2.d_year between 1998 AND 1998 + 2 + and d2.d_year between 2000 AND 2000 + 2 intersect select iws.i_brand_id ,iws.i_class_id @@ -31,7 +31,7 @@ with cross_items as ,{{date_dim}} d3 where ws_item_sk = iws.i_item_sk and ws_sold_date_sk = d3.d_date_sk - and d3.d_year between 1998 AND 1998 + 2) a + and d3.d_year between 2000 AND 2000 + 2) a where i_brand_id = brand_id and i_class_id = class_id and i_category_id = category_id @@ -43,21 +43,21 @@ with cross_items as from {{store_sales}} ,{{date_dim}} where ss_sold_date_sk = d_date_sk - and d_year between 1998 and 1998 + 2 - union all - select cs_quantity quantity + and d_year between 2000 and 2000 + 2 + union all + select cs_quantity quantity ,cs_list_price list_price from {{catalog_sales}} ,{{date_dim}} where cs_sold_date_sk = d_date_sk - and d_year between 1998 and 1998 + 2 + and d_year between 2000 and 2000 + 2 union all select ws_quantity quantity ,ws_list_price list_price from {{web_sales}} ,{{date_dim}} where ws_sold_date_sk = d_date_sk - and d_year between 1998 and 1998 + 2) x) + and d_year between 2000 and 2000 + 2) x) select channel, i_brand_id,i_class_id,i_category_id,sum(sales), sum(number_sales) from( select 'store' channel, i_brand_id,i_class_id @@ -69,7 +69,7 @@ with cross_items as where ss_item_sk in (select ss_item_sk from cross_items) and ss_item_sk = i_item_sk and ss_sold_date_sk = d_date_sk - and d_year = 1998+2 + and d_year = 2000+2 and d_moy = 11 group by i_brand_id,i_class_id,i_category_id having sum(ss_quantity::numeric*ss_list_price) > (select average_sales from avg_sales) @@ -81,7 +81,7 @@ with cross_items as where cs_item_sk in (select ss_item_sk from cross_items) and cs_item_sk = i_item_sk and cs_sold_date_sk = d_date_sk - and d_year = 1998+2 + and d_year = 2000+2 and d_moy = 11 group by i_brand_id,i_class_id,i_category_id having sum(cs_quantity::numeric*cs_list_price) > (select average_sales from avg_sales) @@ -93,7 +93,7 @@ with cross_items as where ws_item_sk in (select ss_item_sk from cross_items) and ws_item_sk = i_item_sk and ws_sold_date_sk = d_date_sk - and d_year = 1998+2 + and d_year = 2000+2 and d_moy = 11 group by i_brand_id,i_class_id,i_category_id having sum(ws_quantity::numeric*ws_list_price) > (select average_sales from avg_sales) @@ -112,7 +112,7 @@ with cross_items as ,{{date_dim}} d1 where ss_item_sk = iss.i_item_sk and ss_sold_date_sk = d1.d_date_sk - and d1.d_year between 1998 AND 1998 + 2 + and d1.d_year between 2000 AND 2000 + 2 intersect select ics.i_brand_id ,ics.i_class_id @@ -122,7 +122,7 @@ with cross_items as ,{{date_dim}} d2 where cs_item_sk = ics.i_item_sk and cs_sold_date_sk = d2.d_date_sk - and d2.d_year between 1998 AND 1998 + 2 + and d2.d_year between 2000 AND 2000 + 2 intersect select iws.i_brand_id ,iws.i_class_id @@ -132,7 +132,7 @@ with cross_items as ,{{date_dim}} d3 where ws_item_sk = iws.i_item_sk and ws_sold_date_sk = d3.d_date_sk - and d3.d_year between 1998 AND 1998 + 2) x + and d3.d_year between 2000 AND 2000 + 2) x where i_brand_id = brand_id and i_class_id = class_id and i_category_id = category_id @@ -144,21 +144,21 @@ with cross_items as from {{store_sales}} ,{{date_dim}} where ss_sold_date_sk = d_date_sk - and d_year between 1998 and 1998 + 2 + and d_year between 2000 and 2000 + 2 union all select cs_quantity quantity ,cs_list_price list_price from {{catalog_sales}} ,{{date_dim}} where cs_sold_date_sk = d_date_sk - and d_year between 1998 and 1998 + 2 + and d_year between 2000 and 2000 + 2 union all select ws_quantity quantity ,ws_list_price list_price from {{web_sales}} ,{{date_dim}} where ws_sold_date_sk = d_date_sk - and d_year between 1998 and 1998 + 2) x) + and d_year between 2000 and 2000 + 2) x) select this_year.channel ty_channel ,this_year.i_brand_id ty_brand ,this_year.i_class_id ty_class @@ -170,11 +170,11 @@ with cross_items as ,last_year.i_class_id ly_class ,last_year.i_category_id ly_category ,last_year.sales ly_sales - ,last_year.number_sales ly_number_sales + ,last_year.number_sales ly_number_sales from (select 'store' channel, i_brand_id,i_class_id,i_category_id ,sum(ss_quantity::numeric*ss_list_price) sales, count(*) number_sales - from {{store_sales}} + from {{store_sales}} ,{{item}} ,{{date_dim}} where ss_item_sk in (select ss_item_sk from cross_items) @@ -182,9 +182,9 @@ with cross_items as and ss_sold_date_sk = d_date_sk and d_week_seq = (select d_week_seq from {{date_dim}} - where d_year = 1998 + 1 + where d_year = 2000 + 1 and d_moy = 12 - and d_dom = 16) + and d_dom = 15) group by i_brand_id,i_class_id,i_category_id having sum(ss_quantity::numeric*ss_list_price) > (select average_sales from avg_sales)) this_year, (select 'store' channel, i_brand_id,i_class_id @@ -197,9 +197,9 @@ with cross_items as and ss_sold_date_sk = d_date_sk and d_week_seq = (select d_week_seq from {{date_dim}} - where d_year = 1998 + where d_year = 2000 and d_moy = 12 - and d_dom = 16) + and d_dom = 15) group by i_brand_id,i_class_id,i_category_id having sum(ss_quantity::numeric*ss_list_price) > (select average_sales from avg_sales)) last_year where this_year.i_brand_id= last_year.i_brand_id diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q15.sql b/ydb/library/benchmarks/queries/tpcds/pg/q15.sql index 230b9c234e41..49208aedce35 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q15.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q15.sql @@ -7,13 +7,13 @@ select ca_zip ,{{customer_address}} ,{{date_dim}} where cs_bill_customer_sk = c_customer_sk - and c_current_addr_sk = ca_address_sk + and c_current_addr_sk = ca_address_sk and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') or ca_state in ('CA','WA','GA') or cs_sales_price > 500::numeric) and cs_sold_date_sk = d_date_sk - and d_qoy = 2 and d_year = 2000 + and d_qoy = 2 and d_year = 1998 group by ca_zip order by ca_zip limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q16.sql b/ydb/library/benchmarks/queries/tpcds/pg/q16.sql index dadb0e5875a4..6d705da117f8 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q16.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q16.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -select +select count(distinct cs_order_number) as "order count" ,sum(cs_ext_ship_cost) as "total shipping cost" ,sum(cs_net_profit) as "total net profit" @@ -10,14 +10,14 @@ from ,{{customer_address}} ,{{call_center}} where - d_date between '1999-2-01'::date and - (cast('1999-2-01' as date) + interval '60' day)::date + d_date between '1999-4-01'::date and + (cast('1999-4-01' as date) + interval '60' day)::date and cs1.cs_ship_date_sk = d_date_sk and cs1.cs_ship_addr_sk = ca_address_sk and ca_state = 'IL' and cs1.cs_call_center_sk = cc_call_center_sk -and cc_county in ('Williamson County','Williamson County','Williamson County','Williamson County', - 'Williamson County' +and cc_county in ('Richland County','Bronx County','Maverick County','Mesa County', + 'Raleigh County' ) and exists (select * from {{catalog_sales}} cs2 diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q17.sql b/ydb/library/benchmarks/queries/tpcds/pg/q17.sql index 21e26c0f6462..be59177b4ccd 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q17.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q17.sql @@ -22,7 +22,7 @@ select i_item_id ,{{date_dim}} d3 ,{{store}} ,{{item}} - where d1.d_quarter_name = '1998Q1' + where d1.d_quarter_name = '2000Q1' and d1.d_date_sk = ss_sold_date_sk and i_item_sk = ss_item_sk and s_store_sk = ss_store_sk @@ -30,11 +30,11 @@ select i_item_id and ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number and sr_returned_date_sk = d2.d_date_sk - and d2.d_quarter_name in ('1998Q1','1998Q2','1998Q3') + and d2.d_quarter_name in ('2000Q1','2000Q2','2000Q3') and sr_customer_sk = cs_bill_customer_sk and sr_item_sk = cs_item_sk and cs_sold_date_sk = d3.d_date_sk - and d3.d_quarter_name in ('1998Q1','1998Q2','1998Q3') + and d3.d_quarter_name in ('2000Q1','2000Q2','2000Q3') group by i_item_id ,i_item_desc ,s_state diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q18.sql b/ydb/library/benchmarks/queries/tpcds/pg/q18.sql index 76dc2956f554..3fe31ab04a9e 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q18.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q18.sql @@ -2,7 +2,7 @@ select i_item_id, ca_country, - ca_state, + ca_state, ca_county, avg( cast(cs_quantity as decimal(12,2))) agg1, avg( cast(cs_list_price as decimal(12,2))) agg2, @@ -11,23 +11,23 @@ select i_item_id, 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, + from {{catalog_sales}}, {{customer_demographics}} cd1, {{customer_demographics}} cd2, {{customer}}, {{customer_address}}, {{date_dim}}, {{item}} where cs_sold_date_sk = d_date_sk and cs_item_sk = i_item_sk and cs_bill_cdemo_sk = cd1.cd_demo_sk and cs_bill_customer_sk = c_customer_sk and - cd1.cd_gender = 'M' and - cd1.cd_education_status = 'College' and + cd1.cd_gender = 'M' and + cd1.cd_education_status = 'Unknown' and c_current_cdemo_sk = cd2.cd_demo_sk and c_current_addr_sk = ca_address_sk and c_birth_month in (9,5,12,4,1,10) and d_year = 2001 and - ca_state in ('ND','WI','AL' - ,'NC','OK','MS','TN') + ca_state in ('AR','TX','NC' + ,'GA','MS','WV','AL') group by rollup (i_item_id, ca_country, ca_state, ca_county) order by ca_country, - ca_state, + ca_state, ca_county, i_item_id limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q19.sql b/ydb/library/benchmarks/queries/tpcds/pg/q19.sql index e313aab18627..bc60e7c58c02 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q19.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q19.sql @@ -5,13 +5,13 @@ select i_brand_id brand_id, i_brand brand, i_manufact_id, i_manufact, from {{date_dim}}, {{store_sales}}, {{item}},{{customer}},{{customer_address}},{{store}} where d_date_sk = ss_sold_date_sk and ss_item_sk = i_item_sk - and i_manager_id=7 - and d_moy=11 - and d_year=1999 - and ss_customer_sk = c_customer_sk + and i_manager_id=16 + and d_moy=12 + and d_year=1998 + and ss_customer_sk = c_customer_sk and c_current_addr_sk = ca_address_sk - and substr(ca_zip,1,5) <> substr(s_zip,1,5) - and ss_store_sk = s_store_sk + and substr(ca_zip,1,5) <> substr(s_zip,1,5) + and ss_store_sk = s_store_sk group by i_brand ,i_brand_id ,i_manufact_id diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q20.sql b/ydb/library/benchmarks/queries/tpcds/pg/q20.sql index e3a8df2fe296..e5f7c1f6c2b7 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q20.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q20.sql @@ -1,23 +1,23 @@ {% include 'header.sql.jinja' %} select i_item_id - ,i_item_desc - ,i_category - ,i_class + ,i_item_desc + ,i_category + ,i_class ,i_current_price - ,sum(cs_ext_sales_price) as itemrevenue + ,sum(cs_ext_sales_price) as itemrevenue ,sum(cs_ext_sales_price)*100::numeric/sum(sum(cs_ext_sales_price)) over (partition by i_class) as revenueratio from {{catalog_sales}} - ,{{item}} + ,{{item}} ,{{date_dim}} - where cs_item_sk = i_item_sk - and i_category in ('Jewelry', 'Sports', 'Books') + where cs_item_sk = i_item_sk + and i_category in ('Shoes', 'Electronics', 'Children') 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' day)::date + and d_date between cast('2001-03-14' as date) + and (cast('2001-03-14' as date) + interval '30' day)::date group by i_item_id - ,i_item_desc + ,i_item_desc ,i_category ,i_class ,i_current_price diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q21.sql b/ydb/library/benchmarks/queries/tpcds/pg/q21.sql index 2799834a6fb9..27d02a3d82b0 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q21.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q21.sql @@ -3,11 +3,11 @@ 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 + ,sum(case when (cast(d_date as date) < cast ('1999-03-20' 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 + ,sum(case when (cast(d_date as date) >= cast ('1999-03-20' as date)) + then inv_quantity_on_hand else 0 end) as inv_after from {{inventory}} ,{{warehouse}} @@ -17,11 +17,11 @@ 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' day)::date - and (cast ('1998-04-08' as date) + interval '30' day)::date + and d_date between (cast ('1999-03-20' as date) - interval '30' day)::date + and (cast ('1999-03-20' as date) + interval '30' day)::date group by w_warehouse_name, i_item_id) x - where (case when inv_before > 0 - then inv_after / inv_before + where (case when inv_before > 0 + then inv_after / inv_before else null::int8 end) between (2.0/3.0)::int8 and (3.0/2.0)::int8 order by w_warehouse_name diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q22.sql b/ydb/library/benchmarks/queries/tpcds/pg/q22.sql index 268ec896dcba..65a8e52e1180 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q22.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q22.sql @@ -10,7 +10,7 @@ select i_product_name ,{{item}} where inv_date_sk=d_date_sk and inv_item_sk=i_item_sk - and d_month_seq between 1212 and 1212 + 11 + and d_month_seq between 1186 and 1186 + 11 group by rollup(i_product_name ,i_brand ,i_class diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q23.sql b/ydb/library/benchmarks/queries/tpcds/pg/q23.sql index 9b6d723f1f1a..2f2c5bbd869c 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q23.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q23.sql @@ -1,24 +1,24 @@ {% include 'header.sql.jinja' %} -with frequent_ss_items as +with frequent_ss_items as (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt from {{store_sales}} - ,{{date_dim}} + ,{{date_dim}} ,{{item}} where ss_sold_date_sk = d_date_sk - and ss_item_sk = i_item_sk - and d_year in (1999,1999+1,1999+2,1999+3) + and ss_item_sk = i_item_sk + and d_year in (2000,2000+1,2000+2,2000+3) group by substr(i_item_desc,1,30),i_item_sk,d_date having count(*) >4), max_store_sales as - (select max(csales) tpcds_cmax + (select max(csales) tpcds_cmax from (select c_customer_sk,sum(ss_quantity::numeric*ss_sales_price) csales from {{store_sales}} ,{{customer}} - ,{{date_dim}} + ,{{date_dim}} where ss_customer_sk = c_customer_sk and ss_sold_date_sk = d_date_sk - and d_year in (1999,1999+1,1999+2,1999+3) + and d_year in (2000,2000+1,2000+2,2000+3) group by c_customer_sk) a), best_ss_customer as (select c_customer_sk,sum(ss_quantity::numeric*ss_sales_price) ssales @@ -33,21 +33,21 @@ from select sum(sales) from (select cs_quantity::numeric*cs_list_price sales from {{catalog_sales}} - ,{{date_dim}} - where d_year = 1999 - and d_moy = 1 - and cs_sold_date_sk = d_date_sk + ,{{date_dim}} + where d_year = 2000 + and d_moy = 3 + and cs_sold_date_sk = d_date_sk and cs_item_sk in (select item_sk from frequent_ss_items) and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) union all select ws_quantity::numeric*ws_list_price sales - from {{web_sales}} - ,{{date_dim}} - where d_year = 1999 - and d_moy = 1 - and ws_sold_date_sk = d_date_sk + from {{web_sales}} + ,{{date_dim}} + where d_year = 2000 + and d_moy = 3 + and ws_sold_date_sk = d_date_sk and ws_item_sk in (select item_sk from frequent_ss_items) - and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) a + and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer)) a limit 100; with frequent_ss_items as (select substr(i_item_desc,1,30) itemdesc,i_item_sk item_sk,d_date solddate,count(*) cnt @@ -56,7 +56,7 @@ with frequent_ss_items as ,{{item}} where ss_sold_date_sk = d_date_sk and ss_item_sk = i_item_sk - and d_year in (1999,1999 + 1,1999 + 2,1999 + 3) + and d_year in (2000,2000 + 1,2000 + 2,2000 + 3) group by substr(i_item_desc,1,30),i_item_sk,d_date having count(*) >4), max_store_sales as @@ -64,10 +64,10 @@ with frequent_ss_items as from (select c_customer_sk,sum(ss_quantity::numeric*ss_sales_price) csales from {{store_sales}} ,{{customer}} - ,{{date_dim}} + ,{{date_dim}} where ss_customer_sk = c_customer_sk and ss_sold_date_sk = d_date_sk - and d_year in (1999,1999+1,1999+2,1999+3) + and d_year in (2000,2000+1,2000+2,2000+3) group by c_customer_sk) a), best_ss_customer as (select c_customer_sk,sum(ss_quantity::numeric*ss_sales_price) ssales @@ -82,22 +82,22 @@ with frequent_ss_items as from (select c_last_name,c_first_name,sum(cs_quantity::numeric*cs_list_price) sales from {{catalog_sales}} ,{{customer}} - ,{{date_dim}} - where d_year = 1999 - and d_moy = 1 - and cs_sold_date_sk = d_date_sk + ,{{date_dim}} + where d_year = 2000 + and d_moy = 3 + and cs_sold_date_sk = d_date_sk and cs_item_sk in (select item_sk from frequent_ss_items) and cs_bill_customer_sk in (select c_customer_sk from best_ss_customer) - and cs_bill_customer_sk = c_customer_sk + and cs_bill_customer_sk = c_customer_sk group by c_last_name,c_first_name union all select c_last_name,c_first_name,sum(ws_quantity::numeric*ws_list_price) sales from {{web_sales}} ,{{customer}} - ,{{date_dim}} - where d_year = 1999 - and d_moy = 1 - and ws_sold_date_sk = d_date_sk + ,{{date_dim}} + where d_year = 2000 + and d_moy = 3 + and ws_sold_date_sk = d_date_sk and ws_item_sk in (select item_sk from frequent_ss_items) and ws_bill_customer_sk in (select c_customer_sk from best_ss_customer) and ws_bill_customer_sk = c_customer_sk diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q24.sql b/ydb/library/benchmarks/queries/tpcds/pg/q24.sql index 9ddb0b6e8e29..b83b66c55622 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q24.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q24.sql @@ -26,7 +26,7 @@ where ss_ticket_number = sr_ticket_number and c_current_addr_sk = ca_address_sk and c_birth_country <> upper(ca_country) and s_zip = ca_zip -and s_market_id=7 +and s_market_id=10 group by c_last_name ,c_first_name ,s_store_name @@ -42,7 +42,7 @@ select c_last_name ,s_store_name ,sum(netpaid) paid from ssales -where i_color = 'orchid' +where i_color = 'show' group by c_last_name ,c_first_name ,s_store_name @@ -78,7 +78,7 @@ where ss_ticket_number = sr_ticket_number and c_current_addr_sk = ca_address_sk and c_birth_country <> upper(ca_country) and s_zip = ca_zip - and s_market_id = 7 + and s_market_id = 10 group by c_last_name ,c_first_name ,s_store_name diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q26.sql b/ydb/library/benchmarks/queries/tpcds/pg/q26.sql index b4684359dfd0..d06ed09c143b 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q26.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q26.sql @@ -1,20 +1,20 @@ {% include 'header.sql.jinja' %} -select i_item_id, +select i_item_id, avg(cs_quantity) agg1, avg(cs_list_price) agg2, avg(cs_coupon_amt) agg3, - avg(cs_sales_price) agg4 + avg(cs_sales_price) agg4 from {{catalog_sales}}, {{customer_demographics}}, {{date_dim}}, {{item}}, {{promotion}} where cs_sold_date_sk = d_date_sk and cs_item_sk = i_item_sk and cs_bill_cdemo_sk = cd_demo_sk and cs_promo_sk = p_promo_sk and - cd_gender = 'F' and + cd_gender = 'F' and cd_marital_status = 'W' and - cd_education_status = 'Primary' and + cd_education_status = 'College' and (p_channel_email = 'N' or p_channel_event = 'N') and - d_year = 1998 + d_year = 1998 group by i_item_id order by i_item_id limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q27.sql b/ydb/library/benchmarks/queries/tpcds/pg/q27.sql index 7027961300b4..d676427bca28 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q27.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q27.sql @@ -13,9 +13,9 @@ select i_item_id, ss_cdemo_sk = cd_demo_sk and cd_gender = 'F' and cd_marital_status = 'W' and - cd_education_status = 'Primary' and - d_year = 1998 and - s_state in ('TN','TN', 'TN', 'TN', 'TN', 'TN') + cd_education_status = '2 yr Degree' and + d_year = 2000 and + s_state in ('AL','IN', 'SC', 'NY', 'OH', 'FL') group by rollup (i_item_id, s_state) order by i_item_id ,s_state diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q28.sql b/ydb/library/benchmarks/queries/tpcds/pg/q28.sql index 1058e5f72bfa..43eeb76f7464 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q28.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q28.sql @@ -6,49 +6,49 @@ from (select avg(ss_list_price) B1_LP ,count(distinct ss_list_price) B1_CNTD from {{store_sales}} where ss_quantity between 0 and 5 - and (ss_list_price between 11::numeric and (11+10)::numeric - or ss_coupon_amt between 460::numeric and (460+1000)::numeric - or ss_wholesale_cost between 14::numeric and (14+20)::numeric)) B1, + and (ss_list_price between 73::numeric and (73+10)::numeric + or ss_coupon_amt between 7826::numeric and (7826+1000)::numeric + or ss_wholesale_cost between 70::numeric and (70+20)::numeric)) 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::numeric and (91+10)::numeric - or ss_coupon_amt between 1430::numeric and (1430+1000)::numeric - or ss_wholesale_cost between 32::numeric and (32+20)::numeric)) B2, + and (ss_list_price between 152::numeric and (152+10)::numeric + or ss_coupon_amt between 2196::numeric and (2196+1000)::numeric + or ss_wholesale_cost between 56::numeric and (56+20)::numeric)) 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::numeric and (66+10)::numeric - or ss_coupon_amt between 920::numeric and (920+1000)::numeric - or ss_wholesale_cost between 4::numeric and (4+20)::numeric)) B3, + and (ss_list_price between 53::numeric and (53+10)::numeric + or ss_coupon_amt between 3430::numeric and (3430+1000)::numeric + or ss_wholesale_cost between 13::numeric and (13+20)::numeric)) 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::numeric and (142+10)::numeric - or ss_coupon_amt between 3054::numeric and (3054+1000)::numeric - or ss_wholesale_cost between 80::numeric and (80+20)::numeric)) B4, + and (ss_list_price between 186::numeric and (186+10)::numeric + or ss_coupon_amt between 3262::numeric and (3262+1000)::numeric + or ss_wholesale_cost between 20::numeric and (20+20)::numeric)) 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::numeric and (135+10)::numeric - or ss_coupon_amt between 14180::numeric and (14180+1000)::numeric - or ss_wholesale_cost between 38::numeric and (38+20)::numeric)) B5, + and (ss_list_price between 85::numeric and (85+10)::numeric + or ss_coupon_amt between 3310::numeric and (3310+1000)::numeric + or ss_wholesale_cost between 37::numeric and (37+20)::numeric)) 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::numeric and (28+10)::numeric - or ss_coupon_amt between 2513::numeric and (2513+1000)::numeric - or ss_wholesale_cost between 42::numeric and (42+20)::numeric)) B6 + and (ss_list_price between 180::numeric and (180+10)::numeric + or ss_coupon_amt between 12592::numeric and (12592+1000)::numeric + or ss_wholesale_cost between 22::numeric and (22+20)::numeric)) B6 limit 100; -- end query 1 in stream 0 using template ../query_templates/query28.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q29.sql b/ydb/library/benchmarks/queries/tpcds/pg/q29.sql index 07fa68cec489..f3974e77511b 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q29.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q29.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -select +select i_item_id ,i_item_desc ,s_store_id @@ -18,8 +18,8 @@ select ,{{store}} ,{{item}} where - d1.d_moy = 4 - and d1.d_year = 1999 + d1.d_moy = 4 + and d1.d_year = 1998 and d1.d_date_sk = ss_sold_date_sk and i_item_sk = ss_item_sk and s_store_sk = ss_store_sk @@ -27,19 +27,19 @@ select and ss_item_sk = sr_item_sk and ss_ticket_number = sr_ticket_number and sr_returned_date_sk = d2.d_date_sk - and d2.d_moy between 4 and 4 + 3 - and d2.d_year = 1999 + and d2.d_moy between 4 and 4 + 3 + and d2.d_year = 1998 and sr_customer_sk = cs_bill_customer_sk and sr_item_sk = cs_item_sk - and cs_sold_date_sk = d3.d_date_sk - and d3.d_year in (1999,1999+1,1999+2) + and cs_sold_date_sk = d3.d_date_sk + and d3.d_year in (1998,1998+1,1998+2) group by i_item_id ,i_item_desc ,s_store_id ,s_store_name order by - i_item_id + i_item_id ,i_item_desc ,s_store_id ,s_store_name diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q30.sql b/ydb/library/benchmarks/queries/tpcds/pg/q30.sql index 30aca5534e5b..18854ad6a28c 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q30.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q30.sql @@ -2,14 +2,14 @@ with customer_total_return as (select wr_returning_customer_sk as ctr_customer_sk - ,ca_state as ctr_state, + ,ca_state as ctr_state, sum(wr_return_amt) as ctr_total_return from {{web_returns}} ,{{date_dim}} ,{{customer_address}} - where wr_returned_date_sk = d_date_sk - and d_year =2002 - and wr_returning_addr_sk = ca_address_sk + where wr_returned_date_sk = d_date_sk + and d_year =2000 + and wr_returning_addr_sk = ca_address_sk group by wr_returning_customer_sk ,ca_state) select c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag @@ -19,10 +19,10 @@ with customer_total_return as ,{{customer_address}} ,{{customer}} where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2::numeric - from customer_total_return ctr2 + from customer_total_return ctr2 where ctr1.ctr_state = ctr2.ctr_state) and ca_address_sk = c_current_addr_sk - and ca_state = 'IL' + and ca_state = 'GA' and ctr1.ctr_customer_sk = c_customer_sk order by c_customer_id,c_salutation,c_first_name,c_last_name,c_preferred_cust_flag ,c_birth_day,c_birth_month,c_birth_year,c_birth_country,c_login,c_email_address diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q31.sql b/ydb/library/benchmarks/queries/tpcds/pg/q31.sql index 4e89636d1916..f737eb1484ab 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q31.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q31.sql @@ -12,7 +12,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 ss1.ca_county ,ss1.d_year ,ws2.web_sales/ws1.web_sales web_q1_q2_increase @@ -28,23 +28,23 @@ with ss as ,ws ws3 where ss1.d_qoy = 1 - and ss1.d_year = 2000 + and ss1.d_year = 1999 and ss1.ca_county = ss2.ca_county and ss2.d_qoy = 2 - and ss2.d_year = 2000 + and ss2.d_year = 1999 and ss2.ca_county = ss3.ca_county and ss3.d_qoy = 3 - and ss3.d_year = 2000 + and ss3.d_year = 1999 and ss1.ca_county = ws1.ca_county and ws1.d_qoy = 1 - and ws1.d_year = 2000 + and ws1.d_year = 1999 and ws1.ca_county = ws2.ca_county and ws2.d_qoy = 2 - and ws2.d_year = 2000 + and ws2.d_year = 1999 and ws1.ca_county = ws3.ca_county and ws3.d_qoy = 3 - and ws3.d_year =2000 - and case when ws1.web_sales > 0::numeric then ws2.web_sales/ws1.web_sales else null::numeric end + and ws3.d_year =1999 + and case when ws1.web_sales > 0::numeric then ws2.web_sales/ws1.web_sales else null::numeric end > case when ss1.store_sales > 0::numeric then ss2.store_sales/ss1.store_sales else null::numeric end and case when ws2.web_sales > 0::numeric then ws3.web_sales/ws2.web_sales else null::numeric end > case when ss2.store_sales > 0::numeric then ss3.store_sales/ss2.store_sales else null::numeric end diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q32.sql b/ydb/library/benchmarks/queries/tpcds/pg/q32.sql index cb3ff8e56ee7..c12057992911 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q32.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q32.sql @@ -1,29 +1,29 @@ {% include 'header.sql.jinja' %} -select sum(cs_ext_discount_amt) as "excess discount amount" -from - {{catalog_sales}} - ,{{item}} +select sum(cs_ext_discount_amt) as "excess discount amount" +from + {{catalog_sales}} + ,{{item}} ,{{date_dim}} where i_manufact_id = 269 -and i_item_sk = cs_item_sk -and d_date between '1998-03-18'::date and - (cast('1998-03-18' as date) + interval '90' day)::date -and d_date_sk = cs_sold_date_sk -and cs_ext_discount_amt - > ( - select - 1.3::numeric * avg(cs_ext_discount_amt) - from - {{catalog_sales}} +and i_item_sk = cs_item_sk +and d_date between '2002-03-29'::date and + (cast('2002-03-29' as date) + interval '90' day)::date +and d_date_sk = cs_sold_date_sk +and cs_ext_discount_amt + > ( + select + 1.3::numeric * avg(cs_ext_discount_amt) + from + {{catalog_sales}} ,{{date_dim}} - where - cs_item_sk = i_item_sk - and d_date between '1998-03-18'::date and - (cast('1998-03-18' as date) + interval '90' day)::date - and d_date_sk = cs_sold_date_sk - ) + where + cs_item_sk = i_item_sk + and d_date between '2002-03-29'::date and + (cast('2002-03-29' as date) + interval '90' day)::date + and d_date_sk = cs_sold_date_sk + ) limit 100; -- end query 1 in stream 0 using template ../query_templates/query32.tpl diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q33.sql b/ydb/library/benchmarks/queries/tpcds/pg/q33.sql index 548c2e5b9c19..3452dd066bea 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q33.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q33.sql @@ -13,13 +13,13 @@ with ss as ( i_manufact_id from {{item}} -where i_category in ('Books')) +where i_category in ('Home')) and ss_item_sk = i_item_sk and ss_sold_date_sk = d_date_sk - and d_year = 1999 - and d_moy = 3 + and d_year = 1998 + and d_moy = 5 and ss_addr_sk = ca_address_sk - and ca_gmt_offset = -5::numeric + and ca_gmt_offset = -6::numeric group by i_manufact_id), cs as ( select @@ -37,10 +37,10 @@ from where i_category in ('Books')) and cs_item_sk = i_item_sk and cs_sold_date_sk = d_date_sk - and d_year = 1999 - and d_moy = 3 + and d_year = 1998 + and d_moy = 5 and cs_bill_addr_sk = ca_address_sk - and ca_gmt_offset = -5::numeric + and ca_gmt_offset = -6::numeric group by i_manufact_id), ws as ( select @@ -58,15 +58,15 @@ from where i_category in ('Books')) and ws_item_sk = i_item_sk and ws_sold_date_sk = d_date_sk - and d_year = 1999 - and d_moy = 3 + and d_year = 1998 + and d_moy = 5 and ws_bill_addr_sk = ca_address_sk - and ca_gmt_offset = -5::numeric + and ca_gmt_offset = -6::numeric group by i_manufact_id) select i_manufact_id ,sum(total_sales) total_sales - from (select * from ss + from (select * from ss union all - select * from cs + select * from cs union all select * from ws) tmp1 group by i_manufact_id diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q34.sql b/ydb/library/benchmarks/queries/tpcds/pg/q34.sql index a20c13ffd5ae..627c46bac6c7 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q34.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q34.sql @@ -11,19 +11,19 @@ select c_last_name ,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_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 = '>10000' or household_demographics.hd_buy_potential = 'Unknown') 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 + and (case when household_demographics.hd_vehicle_count > 0 + then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null::int4 end)::numeric > 1.2 - and date_dim.d_year in (1998,1998+1,1998+2) - and store.s_county in ('Williamson County','Williamson County','Williamson County','Williamson County', - 'Williamson County','Williamson County','Williamson County','Williamson County') + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Salem County','Terrell County','Arthur County','Oglethorpe County', + 'Lunenburg County','Perry County','Halifax County','Sumner County') group by ss_ticket_number,ss_customer_sk) dn,{{customer}} where ss_customer_sk = c_customer_sk and cnt between 15::int8 and 20::int8 diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q35.sql b/ydb/library/benchmarks/queries/tpcds/pg/q35.sql index 7e52de35b276..981d45ed926f 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q35.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q35.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -select +select ca_state, cd_gender, cd_marital_status, @@ -23,24 +23,24 @@ select {{customer}} c,{{customer_address}} ca,{{customer_demographics}} where c.c_current_addr_sk = ca.ca_address_sk and - cd_demo_sk = c.c_current_cdemo_sk and + cd_demo_sk = c.c_current_cdemo_sk and exists (select * from {{store_sales}},{{date_dim}} where c.c_customer_sk = ss_customer_sk and ss_sold_date_sk = d_date_sk and - d_year = 1999 and + d_year = 2001 and d_qoy < 4) and (exists (select * from {{web_sales}},{{date_dim}} where c.c_customer_sk = ws_bill_customer_sk and ws_sold_date_sk = d_date_sk and - d_year = 1999 and - d_qoy < 4) or - exists (select * + d_year = 2001 and + d_qoy < 4) or + exists (select * from {{catalog_sales}},{{date_dim}} where c.c_customer_sk = cs_ship_customer_sk and cs_sold_date_sk = d_date_sk and - d_year = 1999 and + d_year = 2001 and d_qoy < 4)) group by ca_state, cd_gender, diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q36.sql b/ydb/library/benchmarks/queries/tpcds/pg/q36.sql index e69b0bbcf9fd..0ffca8b4c651 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q36.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q36.sql @@ -1,13 +1,13 @@ {% include 'header.sql.jinja' %} -select +select sum(ss_net_profit)/sum(ss_ext_sales_price) as gross_margin ,i_category ,i_class ,grouping(i_category)+grouping(i_class) as lochierarchy ,rank() over ( partition by grouping(i_category)+grouping(i_class), - case when grouping(i_class) = 0 then i_category end + case when grouping(i_class) = 0 then i_category end order by sum(ss_net_profit)/sum(ss_ext_sales_price) asc) as rank_within_parent from {{store_sales}} @@ -15,12 +15,12 @@ select ,{{item}} ,{{store}} where - d1.d_year = 2000 + d1.d_year = 1999 and d1.d_date_sk = ss_sold_date_sk - and i_item_sk = ss_item_sk + and i_item_sk = ss_item_sk and s_store_sk = ss_store_sk - and s_state in ('TN','TN','TN','TN', - 'TN','TN','TN','TN') + and s_state in ('IN','AL','MI','MN', + 'TN','LA','FL','NM') group by rollup(i_category,i_class) order by lochierarchy desc diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q37.sql b/ydb/library/benchmarks/queries/tpcds/pg/q37.sql index a8689bb8fdd3..0b4f489c88e7 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q37.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q37.sql @@ -4,11 +4,11 @@ select i_item_id ,i_item_desc ,i_current_price from {{item}}, {{inventory}}, {{date_dim}}, {{catalog_sales}} - where i_current_price between 22::numeric and (22 + 30)::numeric + where i_current_price between 39::numeric and (39 + 30)::numeric 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' day)::date - and i_manufact_id in (678,964,918,849) + and d_date between cast('2001-01-16' as date) and (cast('2001-01-16' as date) + interval '60' day)::date + and i_manufact_id in (765,886,889,728) and inv_quantity_on_hand between 100 and 500 and cs_item_sk = i_item_sk group by i_item_id,i_item_desc,i_current_price diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q38.sql b/ydb/library/benchmarks/queries/tpcds/pg/q38.sql index 43d1a4894c1a..b393bcd354bd 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q38.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q38.sql @@ -5,19 +5,19 @@ select count(*) from ( from {{store_sales}}, {{date_dim}}, {{customer}} where store_sales.ss_sold_date_sk = date_dim.d_date_sk and store_sales.ss_customer_sk = customer.c_customer_sk - and d_month_seq between 1212 and 1212 + 11 + and d_month_seq between 1186 and 1186 + 11 intersect select distinct c_last_name, c_first_name, d_date from {{catalog_sales}}, {{date_dim}}, {{customer}} where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk - and d_month_seq between 1212 and 1212 + 11 + and d_month_seq between 1186 and 1186 + 11 intersect select distinct c_last_name, c_first_name, d_date from {{web_sales}}, {{date_dim}}, {{customer}} where web_sales.ws_sold_date_sk = date_dim.d_date_sk and web_sales.ws_bill_customer_sk = customer.c_customer_sk - and d_month_seq between 1212 and 1212 + 11 + and d_month_seq between 1186 and 1186 + 11 ) hot_cust limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q39.sql b/ydb/library/benchmarks/queries/tpcds/pg/q39.sql index 003b7eb3dd1e..8295d67d9eda 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q39.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q39.sql @@ -12,7 +12,7 @@ with inv as where inv_item_sk = i_item_sk and inv_warehouse_sk = w_warehouse_sk and inv_date_sk = d_date_sk - and d_year =1998 + and d_year =2000 group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo where case mean when 0::numeric then 0::numeric else stdev/mean end > 1::numeric) select inv1.w_warehouse_sk as inv1_w_warehouse_sk,inv1.i_item_sk as inv1_i_item_sk,inv1.d_moy as inv1_d_moy,inv1.mean as inv1_mean, inv1.cov as inv1_cov @@ -20,8 +20,8 @@ select inv1.w_warehouse_sk as inv1_w_warehouse_sk,inv1.i_item_sk as inv1_i_item_ from inv inv1,inv inv2 where inv1.i_item_sk = inv2.i_item_sk and inv1.w_warehouse_sk = inv2.w_warehouse_sk - and inv1.d_moy=4 - and inv2.d_moy=4+1 + and inv1.d_moy=2 + and inv2.d_moy=2+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 ; @@ -37,7 +37,7 @@ with inv as where inv_item_sk = i_item_sk and inv_warehouse_sk = w_warehouse_sk and inv_date_sk = d_date_sk - and d_year =1998 + and d_year =2000 group by w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy) foo where case mean when 0::numeric then 0::numeric else stdev/mean end > 1::numeric) select inv1.w_warehouse_sk as inv1_w_warehouse_sk,inv1.i_item_sk as inv1_i_item_sk,inv1.d_moy as inv1_d_moy,inv1.mean as inv1_mean, inv1.cov as inv1_cov @@ -45,8 +45,8 @@ select inv1.w_warehouse_sk as inv1_w_warehouse_sk,inv1.i_item_sk as inv1_i_item_ from inv inv1,inv inv2 where inv1.i_item_sk = inv2.i_item_sk and inv1.w_warehouse_sk = inv2.w_warehouse_sk - and inv1.d_moy=4 - and inv2.d_moy=4+1 + and inv1.d_moy=2 + and inv2.d_moy=2+1 and inv1.cov > 1.5::numeric order by inv1_w_warehouse_sk,inv1_i_item_sk,inv1_d_moy,inv1_mean,inv1_cov ,inv2_d_moy,inv2_mean, inv2_cov diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q40.sql b/ydb/library/benchmarks/queries/tpcds/pg/q40.sql index dba570ec94b5..70892eb04733 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q40.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q40.sql @@ -1,26 +1,26 @@ {% include 'header.sql.jinja' %} -select +select w_state ,i_item_id - ,sum(case when (cast(d_date as date) < cast ('1998-04-08' as date)) + ,sum(case when (cast(d_date as date) < cast ('2000-03-18' as date)) then cs_sales_price - coalesce(cr_refunded_cash,0::numeric) else 0::numeric end) as sales_before - ,sum(case when (cast(d_date as date) >= cast ('1998-04-08' as date)) + ,sum(case when (cast(d_date as date) >= cast ('2000-03-18' as date)) then cs_sales_price - coalesce(cr_refunded_cash,0::numeric) else 0::numeric end) as sales_after from {{catalog_sales}} left outer join {{catalog_returns}} on - (cs_order_number = cr_order_number + (cs_order_number = cr_order_number and cs_item_sk = cr_item_sk) - ,{{warehouse}} + ,{{warehouse}} ,{{item}} ,{{date_dim}} where i_current_price between 0.99::numeric and 1.49::numeric and i_item_sk = cs_item_sk - and cs_warehouse_sk = w_warehouse_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' day)::date - and (cast ('1998-04-08' as date) + interval '30' day)::date + and d_date between (cast ('2000-03-18' as date) - interval '30' day)::date + and (cast ('2000-03-18' as date) + interval '30' day)::date group by w_state,i_item_id order by w_state,i_item_id diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q41.sql b/ydb/library/benchmarks/queries/tpcds/pg/q41.sql index 36651838bfee..e406801e3d53 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q41.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q41.sql @@ -2,51 +2,51 @@ select distinct(i_product_name) from {{item}} i1 - where i_manufact_id between 742 and 742+40 + where i_manufact_id between 970 and 970+40 and (select count(*) as item_cnt from {{item}} where (i_manufact = i1.i_manufact and - ((i_category = 'Women' and - (i_color = 'orchid' or i_color = 'papaya') and - (i_units = 'Pound' or i_units = 'Lb') and - (i_size = 'petite' or i_size = 'medium') + ((i_category = 'Women' and + (i_color = 'frosted' or i_color = 'rose') and + (i_units = 'Lb' or i_units = 'Gross') and + (i_size = 'medium' or i_size = 'large') ) or (i_category = 'Women' and - (i_color = 'burlywood' or i_color = 'navy') and - (i_units = 'Bundle' or i_units = 'Each') and - (i_size = 'N/A' or i_size = 'extra large') + (i_color = 'chocolate' or i_color = 'black') and + (i_units = 'Box' or i_units = 'Dram') and + (i_size = 'economy' or i_size = 'petite') ) or (i_category = 'Men' and - (i_color = 'bisque' or i_color = 'azure') and - (i_units = 'N/A' or i_units = 'Tsp') and - (i_size = 'small' or i_size = 'large') + (i_color = 'slate' or i_color = 'magenta') and + (i_units = 'Carton' or i_units = 'Bundle') and + (i_size = 'N/A' or i_size = 'small') ) or (i_category = 'Men' and - (i_color = 'chocolate' or i_color = 'cornflower') and - (i_units = 'Bunch' or i_units = 'Gross') and - (i_size = 'petite' or i_size = 'medium') + (i_color = 'cornflower' or i_color = 'firebrick') and + (i_units = 'Pound' or i_units = 'Oz') and + (i_size = 'medium' or i_size = 'large') ))) 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 - (i_size = 'petite' or i_size = 'medium') + ((i_category = 'Women' and + (i_color = 'almond' or i_color = 'steel') and + (i_units = 'Tsp' or i_units = 'Case') and + (i_size = 'medium' or i_size = 'large') ) or (i_category = 'Women' and - (i_color = 'snow' or i_color = 'steel') and - (i_units = 'Carton' or i_units = 'Tbl') and - (i_size = 'N/A' or i_size = 'extra large') + (i_color = 'purple' or i_color = 'aquamarine') and + (i_units = 'Bunch' or i_units = 'Gram') and + (i_size = 'economy' or i_size = 'petite') ) or (i_category = 'Men' and - (i_color = 'purple' or i_color = 'gainsboro') and - (i_units = 'Dram' or i_units = 'Unknown') and - (i_size = 'small' or i_size = 'large') + (i_color = 'lavender' or i_color = 'papaya') and + (i_units = 'Pallet' or i_units = 'Cup') and + (i_size = 'N/A' or i_size = 'small') ) or (i_category = 'Men' and - (i_color = 'metallic' or i_color = 'forest') and - (i_units = 'Gram' or i_units = 'Ounce') and - (i_size = 'petite' or i_size = 'medium') - )))) > 0 + (i_color = 'maroon' or i_color = 'cyan') and + (i_units = 'Each' or i_units = 'N/A') and + (i_size = 'medium' or i_size = 'large') + ))) > 0 order by i_product_name limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q43.sql b/ydb/library/benchmarks/queries/tpcds/pg/q43.sql index 9246a8325800..9b06f7191d06 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q43.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q43.sql @@ -11,8 +11,8 @@ select s_store_name, s_store_id, from {{date_dim}}, {{store_sales}}, {{store}} where d_date_sk = ss_sold_date_sk and s_store_sk = ss_store_sk and - s_gmt_offset = -5::numeric and - d_year = 1998 + s_gmt_offset = -6::numeric and + d_year = 2001 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; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q44.sql b/ydb/library/benchmarks/queries/tpcds/pg/q44.sql index 48c97c7547bd..2afe4cde7964 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q44.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q44.sql @@ -3,13 +3,13 @@ select asceding.rnk, i1.i_product_name best_performing, i2.i_product_name worst_performing from(select * from (select item_sk,rank() over (order by rank_col asc) rnk - from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col + from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col from {{store_sales}} ss1 - where ss_store_sk = 2 + where ss_store_sk = 366 group by ss_item_sk having avg(ss_net_profit) > 0.9::numeric*(select avg(ss_net_profit) rank_col from {{store_sales}} - where ss_store_sk = 2 + where ss_store_sk = 366 and ss_hdemo_sk is null group by ss_store_sk))V1)V11 where rnk < 11) asceding, @@ -17,17 +17,17 @@ from(select * from (select item_sk,rank() over (order by rank_col desc) rnk from (select ss_item_sk item_sk,avg(ss_net_profit) rank_col from {{store_sales}} ss1 - where ss_store_sk = 2 + where ss_store_sk = 366 group by ss_item_sk having avg(ss_net_profit) > 0.9::numeric*(select avg(ss_net_profit) rank_col from {{store_sales}} - where ss_store_sk = 2 + where ss_store_sk = 366 and ss_hdemo_sk is null group by ss_store_sk))V2)V21 where rnk < 11) descending, {{item}} i1, {{item}} i2 -where asceding.rnk = descending.rnk +where asceding.rnk = descending.rnk and i1.i_item_sk=asceding.item_sk and i2.i_item_sk=descending.item_sk order by asceding.rnk diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q45.sql b/ydb/library/benchmarks/queries/tpcds/pg/q45.sql index 2af5009cfb58..a9f445475c48 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q45.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q45.sql @@ -3,17 +3,17 @@ select ca_zip, ca_county, sum(ws_sales_price) from {{web_sales}}, {{customer}}, {{customer_address}}, {{date_dim}}, {{item}} where ws_bill_customer_sk = c_customer_sk - and c_current_addr_sk = ca_address_sk - and ws_item_sk = i_item_sk + and c_current_addr_sk = ca_address_sk + and ws_item_sk = i_item_sk and ( substr(ca_zip,1,5) in ('85669', '86197','88274','83405','86475', '85392', '85460', '80348', '81792') - or + or i_item_id in (select i_item_id from {{item}} where i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29) ) ) and ws_sold_date_sk = d_date_sk - and d_qoy = 2 and d_year = 2000 + and d_qoy = 2 and d_year = 1998 group by ca_zip, ca_county order by ca_zip, ca_county limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q46.sql b/ydb/library/benchmarks/queries/tpcds/pg/q46.sql index a67c402b3065..8f0d286c680d 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q46.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q46.sql @@ -5,23 +5,23 @@ select c_last_name ,ca_city ,bought_city ,ss_ticket_number - ,amt,profit + ,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}} + 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_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 = 5 or household_demographics.hd_vehicle_count= 3) and date_dim.d_dow in (6,0) - and date_dim.d_year in (1999,1999+1,1999+2) - and store.s_city in ('Midway','Fairview','Fairview','Midway','Fairview') + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_city in ('Five Forks','Oakland','Fairview','Winchester','Farmington') group by ss_ticket_number,ss_customer_sk,ss_addr_sk,ca_city) dn,{{customer}},{{customer_address}} current_addr where ss_customer_sk = c_customer_sk and customer.c_current_addr_sk = current_addr.ca_address_sk diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q47.sql b/ydb/library/benchmarks/queries/tpcds/pg/q47.sql index 121dd8b42105..146aa7b50724 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q47.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q47.sql @@ -18,9 +18,9 @@ with v1 as( ss_sold_date_sk = d_date_sk and ss_store_sk = s_store_sk and ( - d_year = 2000 or - ( d_year = 2000-1 and d_moy =12) or - ( d_year = 2000+1 and d_moy =1) + d_year = 1999 or + ( d_year = 1999-1 and d_moy =12) or + ( d_year = 1999+1 and d_moy =1) ) group by i_category, i_brand, s_store_name, s_company_name, @@ -43,7 +43,7 @@ with v1 as( v1.rn = v1_lead.rn - 1) select * from v2 - where d_year = 2000 and + where d_year = 1999 and avg_monthly_sales > 0::numeric and case when avg_monthly_sales > 0::numeric then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null::numeric end > 0.1::numeric order by sum_sales - avg_monthly_sales, nsum diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q48.sql b/ydb/library/benchmarks/queries/tpcds/pg/q48.sql index 01ad9af86d77..7b4cc1048b6d 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q48.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q48.sql @@ -4,36 +4,36 @@ select sum (ss_quantity) from {{store_sales}}, {{store}}, {{customer_demographics}}, {{customer_address}}, {{date_dim}} where s_store_sk = ss_store_sk and ss_sold_date_sk = d_date_sk and d_year = 1998 - and + and ( ( cd_demo_sk = ss_cdemo_sk - and + and cd_marital_status = 'M' - and - cd_education_status = '4 yr Degree' - and + and + cd_education_status = 'Unknown' + and ss_sales_price between 100.00::numeric and 150.00::numeric ) or ( cd_demo_sk = ss_cdemo_sk - and - cd_marital_status = 'D' - and - cd_education_status = 'Primary' - and - ss_sales_price between 50.00::numeric and 100.00::numeric + and + cd_marital_status = 'W' + and + cd_education_status = 'College' + and + ss_sales_price between 50.00::numeric and 100.00::numeric ) - or + or ( cd_demo_sk = ss_cdemo_sk - and - cd_marital_status = 'U' - and - cd_education_status = 'Advanced Degree' - and - ss_sales_price between 150.00::numeric and 200.00::numeric + and + cd_marital_status = 'D' + and + cd_education_status = 'Primary' + and + ss_sales_price between 150.00::numeric and 200.00::numeric ) ) and @@ -43,24 +43,24 @@ select sum (ss_quantity) and ca_country = 'United States' and - ca_state in ('KY', 'GA', 'NM') - and ss_net_profit between 0::numeric and 2000::numeric + ca_state in ('MI', 'GA', 'NH') + and ss_net_profit between 0::numeric and 2000::numeric ) or (ss_addr_sk = ca_address_sk and ca_country = 'United States' and - ca_state in ('MT', 'OR', 'IN') - and ss_net_profit between 150::numeric and 3000::numeric + ca_state in ('TX', 'KY', 'SD') + and ss_net_profit between 150::numeric and 3000::numeric ) or (ss_addr_sk = ca_address_sk and ca_country = 'United States' and - ca_state in ('WI', 'MO', 'WV') - and ss_net_profit between 50::numeric and 25000::numeric + ca_state in ('NY', 'OH', 'FL') + and ss_net_profit between 50::numeric and 25000::numeric ) ) ; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q50.sql b/ydb/library/benchmarks/queries/tpcds/pg/q50.sql index 7159e10bdac8..a219a9c5f031 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q50.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q50.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -select +select s_store_name ,s_company_id ,s_street_number @@ -11,14 +11,14 @@ select ,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) and - (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" + ,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" + ,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" ,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}} @@ -26,7 +26,7 @@ from ,{{date_dim}} d1 ,{{date_dim}} d2 where - d2.d_year = 2000 + d2.d_year = 1998 and d2.d_moy = 9 and ss_ticket_number = sr_ticket_number and ss_item_sk = sr_item_sk diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q51.sql b/ydb/library/benchmarks/queries/tpcds/pg/q51.sql index 4876dcf592d2..05818e5a3804 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q51.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q51.sql @@ -8,7 +8,7 @@ select from {{web_sales}} ,{{date_dim}} where ws_sold_date_sk=d_date_sk - and d_month_seq between 1212 and 1212+11 + and d_month_seq between 1214 and 1214+11 and ws_item_sk is not NULL group by ws_item_sk, d_date), store_v1 as ( @@ -19,7 +19,7 @@ select from {{store_sales}} ,{{date_dim}} where ss_sold_date_sk=d_date_sk - and d_month_seq between 1212 and 1212+11 + and d_month_seq between 1214 and 1214+11 and ss_item_sk is not NULL group by ss_item_sk, d_date) select * diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q52.sql b/ydb/library/benchmarks/queries/tpcds/pg/q52.sql index a8b16b7334a3..9a98de15c804 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q52.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q52.sql @@ -11,7 +11,7 @@ select dt.d_year 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 dt.d_year=2000 group by dt.d_year ,item.i_brand ,item.i_brand_id diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q54.sql b/ydb/library/benchmarks/queries/tpcds/pg/q54.sql index 7a27b7f6a871..7c852b20187b 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q54.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q54.sql @@ -3,7 +3,7 @@ with my_customers as ( select distinct c_customer_sk , c_current_addr_sk - from + from ( select cs_sold_date_sk sold_date_sk, cs_bill_customer_sk customer_sk, cs_item_sk item_sk @@ -19,11 +19,11 @@ with my_customers as ( {{customer}} where sold_date_sk = d_date_sk and item_sk = i_item_sk - and i_category = 'Jewelry' - and i_class = 'consignment' + and i_category = 'Books' + and i_class = 'business' and c_customer_sk = cs_or_ws_sales.customer_sk - and d_moy = 3 - and d_year = 1999 + and d_moy = 2 + and d_year = 2000 ) , my_revenue as ( select c_customer_sk, diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q55.sql b/ydb/library/benchmarks/queries/tpcds/pg/q55.sql index f10621b901d1..4cf66c776219 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q55.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q55.sql @@ -5,9 +5,9 @@ select i_brand_id brand_id, i_brand brand, from {{date_dim}}, {{store_sales}}, {{item}} where d_date_sk = ss_sold_date_sk and ss_item_sk = i_item_sk - and i_manager_id=36 - and d_moy=12 - and d_year=2001 + and i_manager_id=13 + and d_moy=11 + and d_year=1999 group by i_brand, i_brand_id order by ext_price desc, i_brand_id limit 100 ; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q57.sql b/ydb/library/benchmarks/queries/tpcds/pg/q57.sql index 02f2d8b25232..e4a8d4ee4e88 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q57.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q57.sql @@ -18,9 +18,9 @@ with v1 as( cs_sold_date_sk = d_date_sk and cc_call_center_sk= cs_call_center_sk and ( - d_year = 2000 or - ( d_year = 2000-1 and d_moy =12) or - ( d_year = 2000+1 and d_moy =1) + d_year = 1999 or + ( d_year = 1999-1 and d_moy =12) or + ( d_year = 1999+1 and d_moy =1) ) group by i_category, i_brand, cc_name , d_year, d_moy), @@ -40,7 +40,7 @@ with v1 as( v1.rn = v1_lead.rn - 1) select * from v2 - where d_year = 2000 and + where d_year = 1999 and avg_monthly_sales > 0::numeric and case when avg_monthly_sales > 0::numeric then abs(sum_sales - avg_monthly_sales) / avg_monthly_sales else null::numeric end > 0.1::numeric order by sum_sales - avg_monthly_sales, nsum diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q58.sql b/ydb/library/benchmarks/queries/tpcds/pg/q58.sql index 5e7fe7e6e8e5..acd1d33f32a7 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q58.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q58.sql @@ -2,16 +2,16 @@ with ss_items as (select i_item_id item_id - ,sum(ss_ext_sales_price) ss_item_rev + ,sum(ss_ext_sales_price) ss_item_rev from {{store_sales}} ,{{item}} ,{{date_dim}} where ss_item_sk = i_item_sk and d_date in (select d_date from {{date_dim}} - where d_week_seq = (select d_week_seq + where d_week_seq = (select d_week_seq from {{date_dim}} - where d_date = '1998-02-19'::date)) + where d_date = '1998-02-21'::date)) and ss_sold_date_sk = d_date_sk group by i_item_id), cs_items as @@ -23,9 +23,9 @@ with ss_items as where cs_item_sk = i_item_sk and d_date in (select d_date from {{date_dim}} - where d_week_seq = (select d_week_seq + where d_week_seq = (select d_week_seq from {{date_dim}} - where d_date = '1998-02-19'::date)) + where d_date = '1998-02-21'::date)) and cs_sold_date_sk = d_date_sk group by i_item_id), ws_items as @@ -37,9 +37,9 @@ with ss_items as where ws_item_sk = i_item_sk and d_date in (select d_date from {{date_dim}} - where d_week_seq =(select d_week_seq + where d_week_seq =(select d_week_seq from {{date_dim}} - where d_date = '1998-02-19'::date)) + where d_date = '1998-02-21'::date)) and ws_sold_date_sk = d_date_sk group by i_item_id) select ss_items.item_id @@ -52,7 +52,7 @@ with ss_items as ,(ss_item_rev+cs_item_rev+ws_item_rev)/3::numeric average from ss_items,cs_items,ws_items where ss_items.item_id=cs_items.item_id - and ss_items.item_id=ws_items.item_id + and ss_items.item_id=ws_items.item_id and ss_item_rev between 0.9::numeric * cs_item_rev and 1.1::numeric * cs_item_rev and ss_item_rev between 0.9::numeric * ws_item_rev and 1.1::numeric * ws_item_rev and cs_item_rev between 0.9::numeric * ss_item_rev and 1.1::numeric * ss_item_rev diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q59.sql b/ydb/library/benchmarks/queries/tpcds/pg/q59.sql index 4f0382524046..7db3c6257a8f 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q59.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q59.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -with wss as +with wss as (select d_week_seq, ss_store_sk, sum(case when (d_day_name='Sunday') then ss_sales_price else null::numeric end) sun_sales, @@ -26,7 +26,7 @@ with wss as ,fri_sales fri_sales1,sat_sales sat_sales1 from wss,{{store}},{{date_dim}} d where d.d_week_seq = wss.d_week_seq and - ss_store_sk = s_store_sk and + ss_store_sk = s_store_sk and d_month_seq between 1185 and 1185 + 11) y, (select s_store_name s_store_name2,wss.d_week_seq d_week_seq2 ,s_store_id s_store_id2,sun_sales sun_sales2 @@ -35,8 +35,8 @@ with wss as ,fri_sales fri_sales2,sat_sales sat_sales2 from wss,{{store}},{{date_dim}} d where d.d_week_seq = wss.d_week_seq and - ss_store_sk = s_store_sk and - d_month_seq between 1185+ 12 and 1185 + 23) x + ss_store_sk = s_store_sk and + d_month_seq between 1205+ 12 and 1205 + 23) x where s_store_id1=s_store_id2 and d_week_seq1=d_week_seq2-52 order by s_store_name1,s_store_id1,d_week_seq1 diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q60.sql b/ydb/library/benchmarks/queries/tpcds/pg/q60.sql index e055aa5b0642..dbcb48103952 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q60.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q60.sql @@ -16,10 +16,10 @@ from where i_category in ('Children')) and ss_item_sk = i_item_sk and ss_sold_date_sk = d_date_sk - and d_year = 1999 - and d_moy = 9 + and d_year = 1998 + and d_moy = 10 and ss_addr_sk = ca_address_sk - and ca_gmt_offset = -6::numeric + and ca_gmt_offset = -5::numeric group by i_item_id), cs as ( select @@ -37,10 +37,10 @@ from where i_category in ('Children')) and cs_item_sk = i_item_sk and cs_sold_date_sk = d_date_sk - and d_year = 1999 - and d_moy = 9 + and d_year = 1998 + and d_moy = 10 and cs_bill_addr_sk = ca_address_sk - and ca_gmt_offset = -6::numeric + and ca_gmt_offset = -5::numeric group by i_item_id), ws as ( select @@ -58,17 +58,17 @@ from where i_category in ('Children')) and ws_item_sk = i_item_sk and ws_sold_date_sk = d_date_sk - and d_year = 1999 - and d_moy = 9 + and d_year = 1998 + and d_moy = 10 and ws_bill_addr_sk = ca_address_sk - and ca_gmt_offset = -6::numeric + and ca_gmt_offset = -5::numeric group by i_item_id) - select + select i_item_id ,sum(total_sales) total_sales - from (select * from ss + from (select * from ss union all - select * from cs + select * from cs union all select * from ws) tmp1 group by i_item_id diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q61.sql b/ydb/library/benchmarks/queries/tpcds/pg/q61.sql index 5d7b80211a83..809cd179216e 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q61.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q61.sql @@ -8,20 +8,20 @@ from ,{{promotion}} ,{{date_dim}} ,{{customer}} - ,{{customer_address}} + ,{{customer_address}} ,{{item}} where ss_sold_date_sk = d_date_sk and ss_store_sk = s_store_sk and ss_promo_sk = p_promo_sk and ss_customer_sk= c_customer_sk and ca_address_sk = c_current_addr_sk - and ss_item_sk = i_item_sk - and ca_gmt_offset = -7::numeric - and i_category = 'Books' + and ss_item_sk = i_item_sk + and ca_gmt_offset = -6::numeric + and i_category = 'Sports' and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y') - and s_gmt_offset = -7::numeric - and d_year = 1999 - and d_moy = 11) promotional_sales, + and s_gmt_offset = -6::numeric + and d_year = 2001 + and d_moy = 12) promotional_sales, (select sum(ss_ext_sales_price) total from {{store_sales}} ,{{store}} @@ -34,11 +34,11 @@ from and ss_customer_sk= c_customer_sk and ca_address_sk = c_current_addr_sk and ss_item_sk = i_item_sk - and ca_gmt_offset = -7::numeric - and i_category = 'Books' - and s_gmt_offset = -7::numeric - and d_year = 1999 - and d_moy = 11) all_sales + and ca_gmt_offset = -6::numeric + and i_category = 'Sports' + and s_gmt_offset = -6::numeric + and d_year = 2001 + and d_moy = 12) all_sales order by promotions, total limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q62.sql b/ydb/library/benchmarks/queries/tpcds/pg/q62.sql index 39d1bf4e073e..1afbda9b1b8e 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q62.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q62.sql @@ -1,17 +1,17 @@ {% include 'header.sql.jinja' %} -select +select 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) and - (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" + ,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" + ,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" ,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}} @@ -19,7 +19,7 @@ from ,{{web_site}} ,{{date_dim}} where - d_month_seq between 1212 and 1212 + 11 + d_month_seq between 1215 and 1215 + 11 and ws_ship_date_sk = d_date_sk and ws_warehouse_sk = w_warehouse_sk and ws_ship_mode_sk = sm_ship_mode_sk diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q64.sql b/ydb/library/benchmarks/queries/tpcds/pg/q64.sql index 0c352a1e9677..18d2f1ee23f7 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q64.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q64.sql @@ -66,9 +66,9 @@ cross_sales as hd1.hd_income_band_sk = ib1.ib_income_band_sk and hd2.hd_income_band_sk = ib2.ib_income_band_sk and cd1.cd_marital_status <> cd2.cd_marital_status and - i_color in ('maroon','burnished','dim','steel','navajo','chocolate') and - i_current_price between 35::numeric and (35 + 10)::numeric and - i_current_price between (35 + 1)::numeric and (35 + 15)::numeric + i_color in ('azure','gainsboro','misty','blush','hot','lemon') and + i_current_price between 80::numeric and (80 + 10)::numeric and + i_current_price between (80 + 1)::numeric and (80 + 15)::numeric group by i_product_name ,i_item_sk ,s_store_name @@ -108,8 +108,8 @@ select cs1.product_name ,cs2.cnt as cs2_cnt from cross_sales cs1,cross_sales cs2 where cs1.item_sk=cs2.item_sk and - cs1.syear = 2000 and - cs2.syear = 2000 + 1 and + cs1.syear = 1999 and + cs2.syear = 1999 + 1 and cs2.cnt <= cs1.cnt and cs1.store_name = cs2.store_name and cs1.store_zip = cs2.store_zip diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q65.sql b/ydb/library/benchmarks/queries/tpcds/pg/q65.sql index b777309694db..07608edbc6ca 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q65.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q65.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -select +select s_store_name, i_item_desc, sc.revenue, @@ -10,17 +10,17 @@ select from {{store}}, {{item}}, (select ss_store_sk, avg(revenue) as ave from - (select ss_store_sk, ss_item_sk, + (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue from {{store_sales}}, {{date_dim}} - where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11 + where ss_sold_date_sk = d_date_sk and d_month_seq between 1186 and 1186+11 group by ss_store_sk, ss_item_sk) sa group by ss_store_sk) sb, (select ss_store_sk, ss_item_sk, sum(ss_sales_price) as revenue from {{store_sales}}, {{date_dim}} - where ss_sold_date_sk = d_date_sk and d_month_seq between 1212 and 1212+11 + where ss_sold_date_sk = d_date_sk and d_month_seq between 1186 and 1186+11 group by ss_store_sk, ss_item_sk) sc - where sb.ss_store_sk = sc.ss_store_sk and + where sb.ss_store_sk = sc.ss_store_sk and sc.revenue <= 0.1::numeric * sb.ave and s_store_sk = sc.ss_store_sk and i_item_sk = sc.ss_item_sk diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q66.sql b/ydb/library/benchmarks/queries/tpcds/pg/q66.sql index 3fd8dc9ac53f..c87ec6538264 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q66.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q66.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -select +select w_warehouse_name ,w_warehouse_sq_ft ,w_city @@ -46,58 +46,58 @@ select ,sum(nov_net) as nov_net ,sum(dec_net) as dec_net from ( - select + select w_warehouse_name ,w_warehouse_sq_ft ,w_city ,w_county ,w_state ,w_country - ,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers + ,'MSC' || ',' || 'GERMA' as ship_carriers ,d_year as year - ,sum(case when d_moy = 1 + ,sum(case when d_moy = 1 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as jan_sales - ,sum(case when d_moy = 2 + ,sum(case when d_moy = 2 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as feb_sales - ,sum(case when d_moy = 3 + ,sum(case when d_moy = 3 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as mar_sales - ,sum(case when d_moy = 4 + ,sum(case when d_moy = 4 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as apr_sales - ,sum(case when d_moy = 5 + ,sum(case when d_moy = 5 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as may_sales - ,sum(case when d_moy = 6 + ,sum(case when d_moy = 6 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as jun_sales - ,sum(case when d_moy = 7 + ,sum(case when d_moy = 7 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as jul_sales - ,sum(case when d_moy = 8 + ,sum(case when d_moy = 8 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as aug_sales - ,sum(case when d_moy = 9 + ,sum(case when d_moy = 9 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as sep_sales - ,sum(case when d_moy = 10 + ,sum(case when d_moy = 10 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as oct_sales ,sum(case when d_moy = 11 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as nov_sales ,sum(case when d_moy = 12 then ws_sales_price* ws_quantity::numeric else 0::numeric end) as dec_sales - ,sum(case when d_moy = 1 + ,sum(case when d_moy = 1 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as jan_net ,sum(case when d_moy = 2 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as feb_net - ,sum(case when d_moy = 3 + ,sum(case when d_moy = 3 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as mar_net - ,sum(case when d_moy = 4 + ,sum(case when d_moy = 4 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as apr_net - ,sum(case when d_moy = 5 + ,sum(case when d_moy = 5 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as may_net - ,sum(case when d_moy = 6 + ,sum(case when d_moy = 6 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as jun_net - ,sum(case when d_moy = 7 + ,sum(case when d_moy = 7 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as jul_net - ,sum(case when d_moy = 8 + ,sum(case when d_moy = 8 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as aug_net - ,sum(case when d_moy = 9 + ,sum(case when d_moy = 9 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as sep_net - ,sum(case when d_moy = 10 + ,sum(case when d_moy = 10 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as oct_net ,sum(case when d_moy = 11 then ws_net_paid_inc_tax * ws_quantity::numeric else 0::numeric end) as nov_net @@ -115,9 +115,9 @@ select and ws_sold_time_sk = t_time_sk and ws_ship_mode_sk = sm_ship_mode_sk and d_year = 2002 - and t_time between 49530 and 49530+28800 - and sm_carrier in ('DIAMOND','AIRBORNE') - group by + and t_time between 49530 and 49530+28800 + and sm_carrier in ('MSC','GERMA') + group by w_warehouse_name ,w_warehouse_sq_ft ,w_city @@ -126,58 +126,58 @@ select ,w_country ,d_year union all - select + select w_warehouse_name ,w_warehouse_sq_ft ,w_city ,w_county ,w_state ,w_country - ,'DIAMOND' || ',' || 'AIRBORNE' as ship_carriers + ,'MSC' || ',' || 'GERMA' as ship_carriers ,d_year as year - ,sum(case when d_moy = 1 + ,sum(case when d_moy = 1 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as jan_sales - ,sum(case when d_moy = 2 + ,sum(case when d_moy = 2 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as feb_sales - ,sum(case when d_moy = 3 + ,sum(case when d_moy = 3 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as mar_sales - ,sum(case when d_moy = 4 + ,sum(case when d_moy = 4 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as apr_sales - ,sum(case when d_moy = 5 + ,sum(case when d_moy = 5 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as may_sales - ,sum(case when d_moy = 6 + ,sum(case when d_moy = 6 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as jun_sales - ,sum(case when d_moy = 7 + ,sum(case when d_moy = 7 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as jul_sales - ,sum(case when d_moy = 8 + ,sum(case when d_moy = 8 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as aug_sales - ,sum(case when d_moy = 9 + ,sum(case when d_moy = 9 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as sep_sales - ,sum(case when d_moy = 10 + ,sum(case when d_moy = 10 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as oct_sales ,sum(case when d_moy = 11 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as nov_sales ,sum(case when d_moy = 12 then cs_ext_sales_price* cs_quantity::numeric else 0::numeric end) as dec_sales - ,sum(case when d_moy = 1 + ,sum(case when d_moy = 1 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as jan_net - ,sum(case when d_moy = 2 + ,sum(case when d_moy = 2 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as feb_net - ,sum(case when d_moy = 3 + ,sum(case when d_moy = 3 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as mar_net - ,sum(case when d_moy = 4 + ,sum(case when d_moy = 4 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as apr_net - ,sum(case when d_moy = 5 + ,sum(case when d_moy = 5 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as may_net - ,sum(case when d_moy = 6 + ,sum(case when d_moy = 6 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as jun_net - ,sum(case when d_moy = 7 + ,sum(case when d_moy = 7 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as jul_net - ,sum(case when d_moy = 8 + ,sum(case when d_moy = 8 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as aug_net - ,sum(case when d_moy = 9 + ,sum(case when d_moy = 9 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as sep_net - ,sum(case when d_moy = 10 + ,sum(case when d_moy = 10 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as oct_net ,sum(case when d_moy = 11 then cs_net_paid_inc_ship_tax * cs_quantity::numeric else 0::numeric end) as nov_net @@ -195,9 +195,9 @@ select and cs_sold_time_sk = t_time_sk and cs_ship_mode_sk = sm_ship_mode_sk and d_year = 2002 - and t_time between 49530 AND 49530+28800 - and sm_carrier in ('DIAMOND','AIRBORNE') - group by + and t_time between 49530 AND 49530+28800 + and sm_carrier in ('MSC','GERMA') + group by w_warehouse_name ,w_warehouse_sq_ft ,w_city @@ -206,7 +206,7 @@ select ,w_country ,d_year ) x - group by + group by w_warehouse_name ,w_warehouse_sq_ft ,w_city diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q67.sql b/ydb/library/benchmarks/queries/tpcds/pg/q67.sql index 250f5695f7e2..ea18e4ed960f 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q67.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q67.sql @@ -27,7 +27,7 @@ from (select i_category where ss_sold_date_sk=d_date_sk and ss_item_sk=i_item_sk and ss_store_sk = s_store_sk - and d_month_seq between 1212 and 1212+11 + and d_month_seq between 1185 and 1185+11 group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2 where rk <= 100 order by i_category diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q68.sql b/ydb/library/benchmarks/queries/tpcds/pg/q68.sql index 55b5927db0ea..99cdbc4b48e0 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q68.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q68.sql @@ -11,23 +11,23 @@ select c_last_name from (select ss_ticket_number ,ss_customer_sk ,ca_city bought_city - ,sum(ss_ext_sales_price) extended_price + ,sum(ss_ext_sales_price) extended_price ,sum(ss_ext_list_price) list_price - ,sum(ss_ext_tax) extended_tax + ,sum(ss_ext_tax) extended_tax from {{store_sales}} ,{{date_dim}} ,{{store}} ,{{household_demographics}} - ,{{customer_address}} + ,{{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_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 date_dim.d_dom between 1 and 2 and (household_demographics.hd_dep_count = 5 or household_demographics.hd_vehicle_count= 3) and date_dim.d_year in (1999,1999+1,1999+2) - and store.s_city in ('Midway','Fairview') + and store.s_city in ('Pleasant Hill','Bethel') group by ss_ticket_number ,ss_customer_sk ,ss_addr_sk,ca_city) dn diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q69.sql b/ydb/library/benchmarks/queries/tpcds/pg/q69.sql index 63267e64c97f..565c197fa625 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q69.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q69.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -select +select cd_gender, cd_marital_status, cd_education_status, @@ -13,26 +13,26 @@ select {{customer}} c,{{customer_address}} ca,{{customer_demographics}} where c.c_current_addr_sk = ca.ca_address_sk and - ca_state in ('CO','IL','MN') and - cd_demo_sk = c.c_current_cdemo_sk and + ca_state in ('MO','MN','AZ') and + cd_demo_sk = c.c_current_cdemo_sk and exists (select * from {{store_sales}},{{date_dim}} where c.c_customer_sk = ss_customer_sk and ss_sold_date_sk = d_date_sk and - d_year = 1999 and - d_moy between 1 and 1+2) and + d_year = 2003 and + d_moy between 2 and 2+2) and (not exists (select * from {{web_sales}},{{date_dim}} where c.c_customer_sk = ws_bill_customer_sk and ws_sold_date_sk = d_date_sk and - d_year = 1999 and - d_moy between 1 and 1+2) and - not exists (select * + d_year = 2003 and + d_moy between 2 and 2+2) and + not exists (select * from {{catalog_sales}},{{date_dim}} where c.c_customer_sk = cs_ship_customer_sk and cs_sold_date_sk = d_date_sk and - d_year = 1999 and - d_moy between 1 and 1+2)) + d_year = 2003 and + d_moy between 2 and 2+2)) group by cd_gender, cd_marital_status, cd_education_status, diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q70.sql b/ydb/library/benchmarks/queries/tpcds/pg/q70.sql index 8d8f3f0b69fd..850e11c01e04 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q70.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q70.sql @@ -1,20 +1,20 @@ {% include 'header.sql.jinja' %} -select +select sum(ss_net_profit) as total_sum ,s_state ,s_county ,grouping(s_state)+grouping(s_county) as lochierarchy ,rank() over ( partition by grouping(s_state)+grouping(s_county), - case when grouping(s_county) = 0 then s_state end + case when grouping(s_county) = 0 then s_state end order by sum(ss_net_profit) desc) as rank_within_parent from {{store_sales}} ,{{date_dim}} d1 ,{{store}} where - d1.d_month_seq between 1212 and 1212+11 + d1.d_month_seq between 1218 and 1218+11 and d1.d_date_sk = ss_sold_date_sk and s_store_sk = ss_store_sk and s_state in @@ -26,7 +26,7 @@ select and d_date_sk = ss_sold_date_sk and s_store_sk = ss_store_sk group by s_state - ) tmp1 + ) tmp1 where ranking <= 5 ) group by rollup(s_state,s_county) diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q72.sql b/ydb/library/benchmarks/queries/tpcds/pg/q72.sql index f55712f45666..85010145d485 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q72.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q72.sql @@ -18,11 +18,11 @@ join {{date_dim}} d3 on (cs_ship_date_sk = d3.d_date_sk) left outer join {{promotion}} on (cs_promo_sk=p_promo_sk) left outer join {{catalog_returns}} on (cr_item_sk = cs_item_sk and cr_order_number = cs_order_number) where d1.d_week_seq = d2.d_week_seq - and inv_quantity_on_hand < cs_quantity + 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 cd_marital_status = 'M' + and d1.d_year = 2000 + and cd_marital_status = 'D' 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; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q73.sql b/ydb/library/benchmarks/queries/tpcds/pg/q73.sql index ba77f27adaf8..a1716ad8073f 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q73.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q73.sql @@ -3,7 +3,7 @@ select c_last_name ,c_first_name ,c_salutation - ,c_preferred_cust_flag + ,c_preferred_cust_flag ,ss_ticket_number ,cnt from (select ss_ticket_number @@ -11,16 +11,16 @@ select c_last_name ,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_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 date_dim.d_dom between 1 and 2 and (household_demographics.hd_buy_potential = '>10000' or - household_demographics.hd_buy_potential = 'Unknown') + household_demographics.hd_buy_potential = '5001-10000') and household_demographics.hd_vehicle_count > 0 - and case when household_demographics.hd_vehicle_count > 0 then + and case when household_demographics.hd_vehicle_count > 0 then household_demographics.hd_dep_count/ household_demographics.hd_vehicle_count else null::int4 end > 1 - and date_dim.d_year in (1998,1998+1,1998+2) - and store.s_county in ('Williamson County','Williamson County','Williamson County','Williamson County') + and date_dim.d_year in (2000,2000+1,2000+2) + and store.s_county in ('Lea County','Furnas County','Pennington County','Bronx County') group by ss_ticket_number,ss_customer_sk) dj,{{customer}} where ss_customer_sk = c_customer_sk and cnt between 1::int8 and 5::int8 diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q74.sql b/ydb/library/benchmarks/queries/tpcds/pg/q74.sql index c2939c148568..616ad10ce935 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q74.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q74.sql @@ -12,7 +12,7 @@ with year_total as ( ,{{date_dim}} where c_customer_sk = ss_customer_sk and ss_sold_date_sk = d_date_sk - and d_year in (2001,2001+1) + and d_year in (1998,1998+1) group by c_customer_id ,c_first_name ,c_last_name @@ -29,13 +29,13 @@ with year_total as ( ,{{date_dim}} where c_customer_sk = ws_bill_customer_sk and ws_sold_date_sk = d_date_sk - and d_year in (2001,2001+1) + and d_year in (1998,1998+1) group by c_customer_id ,c_first_name ,c_last_name ,d_year ) - select + select t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name from year_total t_s_firstyear ,year_total t_s_secyear @@ -48,10 +48,10 @@ with year_total as ( and t_w_firstyear.sale_type = 'w' and t_s_secyear.sale_type = 's' and t_w_secyear.sale_type = 'w' - and t_s_firstyear.year = 2001 - and t_s_secyear.year = 2001+1 - and t_w_firstyear.year = 2001 - and t_w_secyear.year = 2001+1 + and t_s_firstyear.year = 1998 + and t_s_secyear.year = 1998+1 + and t_w_firstyear.year = 1998 + and t_w_secyear.year = 1998+1 and t_s_firstyear.year_total > 0::numeric and t_w_firstyear.year_total > 0::numeric and case when t_w_firstyear.year_total > 0::numeric then t_w_secyear.year_total / t_w_firstyear.year_total else null::numeric end diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q75.sql b/ydb/library/benchmarks/queries/tpcds/pg/q75.sql index cea7cc7d224f..a379ff35e8da 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q75.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q75.sql @@ -17,7 +17,7 @@ WITH all_sales AS ( ,cs_ext_sales_price - COALESCE(cr_return_amount,0.0::numeric) AS sales_amt FROM {{catalog_sales}} JOIN {{item}} ON i_item_sk=cs_item_sk JOIN {{date_dim}} ON d_date_sk=cs_sold_date_sk - LEFT JOIN {{catalog_returns}} ON (cs_order_number=cr_order_number + LEFT JOIN {{catalog_returns}} ON (cs_order_number=cr_order_number AND cs_item_sk=cr_item_sk) WHERE i_category='Sports' UNION @@ -30,7 +30,7 @@ WITH all_sales AS ( ,ss_ext_sales_price - COALESCE(sr_return_amt,0.0::numeric) AS sales_amt FROM {{store_sales}} JOIN {{item}} ON i_item_sk=ss_item_sk JOIN {{date_dim}} ON d_date_sk=ss_sold_date_sk - LEFT JOIN {{store_returns}} ON (ss_ticket_number=sr_ticket_number + LEFT JOIN {{store_returns}} ON (ss_ticket_number=sr_ticket_number AND ss_item_sk=sr_item_sk) WHERE i_category='Sports' UNION @@ -43,7 +43,7 @@ WITH all_sales AS ( ,ws_ext_sales_price - COALESCE(wr_return_amt,0.0::numeric) AS sales_amt FROM {{web_sales}} JOIN {{item}} ON i_item_sk=ws_item_sk JOIN {{date_dim}} ON d_date_sk=ws_sold_date_sk - LEFT JOIN {{web_returns}} ON (ws_order_number=wr_order_number + LEFT JOIN {{web_returns}} ON (ws_order_number=wr_order_number AND ws_item_sk=wr_item_sk) WHERE i_category='Sports') sales_detail GROUP BY d_year, i_brand_id, i_class_id, i_category_id, i_manufact_id) @@ -62,8 +62,8 @@ WITH all_sales AS ( AND curr_yr.i_class_id=prev_yr.i_class_id AND curr_yr.i_category_id=prev_yr.i_category_id AND curr_yr.i_manufact_id=prev_yr.i_manufact_id - AND curr_yr.d_year=2002 - AND prev_yr.d_year=2002-1 + AND curr_yr.d_year=2001 + AND prev_yr.d_year=2001-1 AND CAST(curr_yr.sales_cnt AS DECIMAL(17,2))/CAST(prev_yr.sales_cnt AS DECIMAL(17,2))<0.9::numeric ORDER BY sales_cnt_diff,sales_amt_diff limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q76.sql b/ydb/library/benchmarks/queries/tpcds/pg/q76.sql index efd65ce1ebae..34a3377530b9 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q76.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q76.sql @@ -1,19 +1,19 @@ {% include 'header.sql.jinja' %} 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 + SELECT 'store' as channel, 'ss_customer_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 ss_sold_date_sk=d_date_sk AND ss_item_sk=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 + SELECT 'web' as channel, 'ws_ship_addr_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 ws_sold_date_sk=d_date_sk AND ws_item_sk=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 + SELECT 'catalog' as channel, 'cs_ship_mode_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 cs_sold_date_sk=d_date_sk diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q77.sql b/ydb/library/benchmarks/queries/tpcds/pg/q77.sql index c1fa589909ae..89bde1b14ca1 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q77.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q77.sql @@ -8,8 +8,8 @@ with ss as {{date_dim}}, {{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' day)::date + and d_date between cast('2000-08-16' as date) + and (cast('2000-08-16' as date) + interval '30' day)::date and ss_store_sk = s_store_sk group by s_store_sk) , @@ -21,10 +21,10 @@ with ss as {{date_dim}}, {{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' day)::date + and d_date between cast('2000-08-16' as date) + and (cast('2000-08-16' as date) + interval '30' day)::date and sr_store_sk = s_store_sk - group by s_store_sk), + group by s_store_sk), cs as (select cs_call_center_sk, sum(cs_ext_sales_price) as sales, @@ -32,10 +32,10 @@ with ss as from {{catalog_sales}}, {{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' day)::date - group by cs_call_center_sk - ), + and d_date between cast('2000-08-16' as date) + and (cast('2000-08-16' as date) + interval '30' day)::date + group by cs_call_center_sk + ), cr as (select cr_call_center_sk, sum(cr_return_amount) as returns, @@ -43,10 +43,10 @@ with ss as from {{catalog_returns}}, {{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' day)::date + and d_date between cast('2000-08-16' as date) + and (cast('2000-08-16' as date) + interval '30' day)::date group by cr_call_center_sk - ), + ), ws as ( select wp_web_page_sk, sum(ws_ext_sales_price) as sales, @@ -55,10 +55,10 @@ with ss as {{date_dim}}, {{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' day)::date + and d_date between cast('2000-08-16' as date) + and (cast('2000-08-16' as date) + interval '30' day)::date and ws_web_page_sk = wp_web_page_sk - group by wp_web_page_sk), + group by wp_web_page_sk), wr as (select wp_web_page_sk, sum(wr_return_amt) as returns, @@ -67,8 +67,8 @@ with ss as {{date_dim}}, {{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' day)::date + and d_date between cast('2000-08-16' as date) + and (cast('2000-08-16' as date) + interval '30' day)::date and wr_web_page_sk = wp_web_page_sk group by wp_web_page_sk) select channel @@ -76,7 +76,7 @@ with ss as , sum(sales) as sales , sum(returns) as returns , sum(profit) as profit - from + from (select 'store channel' as channel , ss.s_store_sk as id , sales diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q78.sql b/ydb/library/benchmarks/queries/tpcds/pg/q78.sql index 1e9176db37bf..e75ede581a9d 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q78.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q78.sql @@ -36,7 +36,7 @@ ss as where sr_ticket_number is null group by d_year, ss_item_sk, ss_customer_sk ) - select + select ss_sold_year, ss_item_sk, ss_customer_sk, round((ss_qty/(coalesce(ws_qty,0::int8)+coalesce(cs_qty,0::int8)))::numeric,2) ratio, ss_qty store_qty, ss_wc store_wholesale_cost, ss_sp store_sales_price, @@ -46,8 +46,8 @@ coalesce(ws_sp,0::numeric)+coalesce(cs_sp,0::numeric) 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 cs_item_sk=ss_item_sk and cs_customer_sk=ss_customer_sk) -where (coalesce(ws_qty,0::int8)>0::int8 or coalesce(cs_qty, 0::int8)>0::int8) and ss_sold_year=2000 -order by +where (coalesce(ws_qty,0::int8)>0::int8 or coalesce(cs_qty, 0::int8)>0::int8) and ss_sold_year=2001 +order by ss_sold_year, ss_item_sk, ss_customer_sk, ss_qty desc, ss_wc desc, ss_sp desc, other_chan_qty, diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q80.sql b/ydb/library/benchmarks/queries/tpcds/pg/q80.sql index a1763ea11b1c..7303e281507f 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q80.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q80.sql @@ -12,8 +12,8 @@ with ssr as {{item}}, {{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' day)::date + and d_date between cast('2002-08-06' as date) + and (cast('2002-08-06' as date) + interval '30' day)::date and ss_store_sk = s_store_sk and ss_item_sk = i_item_sk and i_current_price > 50::numeric @@ -33,8 +33,8 @@ with ssr as {{item}}, {{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' day)::date + and d_date between cast('2002-08-06' as date) + and (cast('2000-08-06' as date) + interval '30' day)::date and cs_catalog_page_sk = cp_catalog_page_sk and cs_item_sk = i_item_sk and i_current_price > 50::numeric @@ -54,8 +54,8 @@ group by cp_catalog_page_id) {{item}}, {{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' day)::date + and d_date between cast('2002-08-06' as date) + and (cast('2002-08-06' as date) + interval '30' day)::date and ws_web_site_sk = web_site_sk and ws_item_sk = i_item_sk and i_current_price > 50::numeric @@ -67,7 +67,7 @@ group by web_site_id) , sum(sales) as sales , sum(returns) as returns , sum(profit) as profit - from + from (select 'store channel' as channel , 'store' || store_id as id , sales diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q81.sql b/ydb/library/benchmarks/queries/tpcds/pg/q81.sql index 70038a284122..0df6a17c6258 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q81.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q81.sql @@ -2,14 +2,14 @@ with customer_total_return as (select cr_returning_customer_sk as ctr_customer_sk - ,ca_state as ctr_state, + ,ca_state as ctr_state, sum(cr_return_amt_inc_tax) as ctr_total_return from {{catalog_returns}} ,{{date_dim}} ,{{customer_address}} - where cr_returned_date_sk = d_date_sk + where cr_returned_date_sk = d_date_sk and d_year =1998 - and cr_returning_addr_sk = ca_address_sk + and cr_returning_addr_sk = ca_address_sk group by cr_returning_customer_sk ,ca_state ) select c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name @@ -19,10 +19,10 @@ with customer_total_return as ,{{customer_address}} ,{{customer}} where ctr1.ctr_total_return > (select avg(ctr_total_return)*1.2::numeric - from customer_total_return ctr2 + from customer_total_return ctr2 where ctr1.ctr_state = ctr2.ctr_state) and ca_address_sk = c_current_addr_sk - and ca_state = 'IL' + and ca_state = 'TX' and ctr1.ctr_customer_sk = c_customer_sk order by c_customer_id,c_salutation,c_first_name,c_last_name,ca_street_number,ca_street_name ,ca_street_type,ca_suite_number,ca_city,ca_county,ca_state,ca_zip,ca_country,ca_gmt_offset diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q82.sql b/ydb/library/benchmarks/queries/tpcds/pg/q82.sql index e10ad4c85e4d..3fce72f30685 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q82.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q82.sql @@ -7,7 +7,7 @@ select i_item_id where i_current_price between 30::numeric and (30+30)::numeric 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' day)::date + and d_date between cast('2001-01-28' as date) and (cast('2001-01-28' as date) + interval '60' day)::date 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 diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q83.sql b/ydb/library/benchmarks/queries/tpcds/pg/q83.sql index ca3aac8c8753..956bfaf6fd1a 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q83.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q83.sql @@ -7,13 +7,13 @@ with sr_items as {{item}}, {{date_dim}} where sr_item_sk = i_item_sk - and d_date in + and d_date in (select d_date from {{date_dim}} - where d_week_seq in + where d_week_seq in (select d_week_seq from {{date_dim}} - where d_date in ('1998-01-02'::date,'1998-10-15'::date,'1998-11-10'::date))) + where d_date in ('2000-06-17'::date,'2000-08-22'::date,'2000-11-17'::date))) and sr_returned_date_sk = d_date_sk group by i_item_id), cr_items as @@ -23,13 +23,13 @@ with sr_items as {{item}}, {{date_dim}} where cr_item_sk = i_item_sk - and d_date in + and d_date in (select d_date from {{date_dim}} - where d_week_seq in + where d_week_seq in (select d_week_seq from {{date_dim}} - where d_date in ('1998-01-02'::date,'1998-10-15'::date,'1998-11-10'::date))) + where d_date in ('2000-06-17'::date,'2000-08-22'::date,'2000-11-17'::date))) and cr_returned_date_sk = d_date_sk group by i_item_id), wr_items as @@ -39,13 +39,13 @@ with sr_items as {{item}}, {{date_dim}} where wr_item_sk = i_item_sk - and d_date in + and d_date in (select d_date from {{date_dim}} - where d_week_seq in + where d_week_seq in (select d_week_seq from {{date_dim}} - where d_date in ('1998-01-02'::date,'1998-10-15'::date,'1998-11-10'::date))) + where d_date in ('2000-06-17'::date,'2000-08-22'::date,'2000-11-17'::date))) and wr_returned_date_sk = d_date_sk group by i_item_id) select sr_items.item_id @@ -60,7 +60,7 @@ with sr_items as ,cr_items ,wr_items where sr_items.item_id=cr_items.item_id - and sr_items.item_id=wr_items.item_id + and sr_items.item_id=wr_items.item_id order by sr_items.item_id ,sr_item_qty limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q84.sql b/ydb/library/benchmarks/queries/tpcds/pg/q84.sql index eab4a4643faf..5368f08b63da 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q84.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q84.sql @@ -10,8 +10,8 @@ select c_customer_id as customer_id ,{{store_returns}} where ca_city = 'Hopewell' and c_current_addr_sk = ca_address_sk - and ib_lower_bound >= 32287 - and ib_upper_bound <= 32287 + 50000 + and ib_lower_bound >= 37855 + and ib_upper_bound <= 37855 + 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 diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q85.sql b/ydb/library/benchmarks/queries/tpcds/pg/q85.sql index 7a25e893c21c..daf099ee33bd 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q85.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q85.sql @@ -5,12 +5,12 @@ select substr(r_reason_desc,1,20) ,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}} + {{customer_demographics}} cd2, {{customer_address}}, {{date_dim}}, {{reason}} where ws_web_page_sk = wp_web_page_sk and ws_item_sk = wr_item_sk and ws_order_number = wr_order_number and ws_sold_date_sk = d_date_sk and d_year = 1998 - and cd1.cd_demo_sk = wr_refunded_cdemo_sk + and cd1.cd_demo_sk = wr_refunded_cdemo_sk and cd2.cd_demo_sk = wr_returning_cdemo_sk and ca_address_sk = wr_refunded_addr_sk and r_reason_sk = wr_reason_sk @@ -22,18 +22,18 @@ select substr(r_reason_desc,1,20) cd1.cd_marital_status = cd2.cd_marital_status and cd1.cd_education_status = '4 yr Degree' - and + and cd1.cd_education_status = cd2.cd_education_status and ws_sales_price between 100.00::numeric and 150.00::numeric ) or ( - cd1.cd_marital_status = 'D' + cd1.cd_marital_status = 'S' and cd1.cd_marital_status = cd2.cd_marital_status and - cd1.cd_education_status = 'Primary' + cd1.cd_education_status = 'College' and cd1.cd_education_status = cd2.cd_education_status and @@ -41,11 +41,11 @@ select substr(r_reason_desc,1,20) ) or ( - cd1.cd_marital_status = 'U' + cd1.cd_marital_status = 'D' and cd1.cd_marital_status = cd2.cd_marital_status and - cd1.cd_education_status = 'Advanced Degree' + cd1.cd_education_status = 'Secondary' and cd1.cd_education_status = cd2.cd_education_status and @@ -57,22 +57,22 @@ select substr(r_reason_desc,1,20) ( ca_country = 'United States' and - ca_state in ('KY', 'GA', 'NM') - and ws_net_profit between 100::numeric and 200::numeric + ca_state in ('TX', 'VA', 'CA') + and ws_net_profit between 100::numeric and 200::numeric ) or ( ca_country = 'United States' and - ca_state in ('MT', 'OR', 'IN') + ca_state in ('AR', 'NE', 'MO') and ws_net_profit between 150::numeric and 300::numeric ) or ( ca_country = 'United States' and - ca_state in ('WI', 'MO', 'WV') - and ws_net_profit between 50::numeric and 250::numeric + ca_state in ('IA', 'MS', 'WA') + and ws_net_profit between 50::numeric and 250::numeric ) ) group by r_reason_desc diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q86.sql b/ydb/library/benchmarks/queries/tpcds/pg/q86.sql index 0805f7648e1a..945c50603c5c 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q86.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q86.sql @@ -1,20 +1,20 @@ {% include 'header.sql.jinja' %} -select +select sum(ws_net_paid) as total_sum ,i_category ,i_class ,grouping(i_category)+grouping(i_class) as lochierarchy ,rank() over ( partition by grouping(i_category)+grouping(i_class), - case when grouping(i_class) = 0 then i_category end + case when grouping(i_class) = 0 then i_category end order by sum(ws_net_paid) desc) as rank_within_parent from {{web_sales}} ,{{date_dim}} d1 ,{{item}} where - d1.d_month_seq between 1212 and 1212+11 + d1.d_month_seq between 1215 and 1215+11 and d1.d_date_sk = ws_sold_date_sk and i_item_sk = ws_item_sk group by rollup(i_category,i_class) diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q87.sql b/ydb/library/benchmarks/queries/tpcds/pg/q87.sql index 0d333ffd001e..253c3cd0272e 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q87.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q87.sql @@ -1,23 +1,23 @@ {% include 'header.sql.jinja' %} -select count(*) +select count(*) from ((select distinct c_last_name, c_first_name, d_date from {{store_sales}}, {{date_dim}}, {{customer}} where store_sales.ss_sold_date_sk = date_dim.d_date_sk and store_sales.ss_customer_sk = customer.c_customer_sk - and d_month_seq between 1212 and 1212+11) + and d_month_seq between 1221 and 1221+11) except (select distinct c_last_name, c_first_name, d_date from {{catalog_sales}}, {{date_dim}}, {{customer}} where catalog_sales.cs_sold_date_sk = date_dim.d_date_sk and catalog_sales.cs_bill_customer_sk = customer.c_customer_sk - and d_month_seq between 1212 and 1212+11) + and d_month_seq between 1221 and 1221+11) except (select distinct c_last_name, c_first_name, d_date from {{web_sales}}, {{date_dim}}, {{customer}} where web_sales.ws_sold_date_sk = date_dim.d_date_sk and web_sales.ws_bill_customer_sk = customer.c_customer_sk - and d_month_seq between 1212 and 1212+11) + and d_month_seq between 1221 and 1221+11) ) cool_cust ; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q89.sql b/ydb/library/benchmarks/queries/tpcds/pg/q89.sql index dcbe23488366..855bed418675 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q89.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q89.sql @@ -14,11 +14,11 @@ where ss_item_sk = i_item_sk and ss_sold_date_sk = d_date_sk and ss_store_sk = s_store_sk and d_year in (2000) and - ((i_category in ('Home','Books','Electronics') and - i_class in ('wallpaper','parenting','musical') + ((i_category in ('Home','Music','Books') and + i_class in ('glassware','classical','fiction') ) - or (i_category in ('Shoes','Jewelry','Men') and - i_class in ('womens','birdal','pants') + or (i_category in ('Jewelry','Sports','Women') and + i_class in ('semi-precious','baseball','dresses') )) group by i_category, i_class, i_brand, s_store_name, s_company_name, d_moy) tmp1 diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q90.sql b/ydb/library/benchmarks/queries/tpcds/pg/q90.sql index 4a8e69a715a2..67a6d4e6f12a 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q90.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q90.sql @@ -6,16 +6,16 @@ select cast(amc as decimal(15,4))/cast(pmc as decimal(15,4)) am_pm_ratio 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 time_dim.t_hour between 9 and 9+1 + and household_demographics.hd_dep_count = 3 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 time_dim.t_hour between 16 and 16+1 + and household_demographics.hd_dep_count = 3 and web_page.wp_char_count between 5000 and 5200) pt order by am_pm_ratio limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q91.sql b/ydb/library/benchmarks/queries/tpcds/pg/q91.sql index 90b8c57075cd..4273a991f243 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q91.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q91.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -select +select cc_call_center_id Call_Center, cc_name Call_Center_Name, cc_manager Manager, @@ -20,11 +20,11 @@ and cr_returning_customer_sk= c_customer_sk and cd_demo_sk = c_current_cdemo_sk and hd_demo_sk = c_current_hdemo_sk and ca_address_sk = c_current_addr_sk -and d_year = 1999 -and d_moy = 11 +and d_year = 2000 +and d_moy = 12 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 hd_buy_potential like 'Unknown%' and ca_gmt_offset = -7::numeric group by cc_call_center_id,cc_name,cc_manager,cd_marital_status,cd_education_status order by sum(cr_net_loss) desc; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q92.sql b/ydb/library/benchmarks/queries/tpcds/pg/q92.sql index 0f5906a8cd34..30f56de91c3b 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q92.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q92.sql @@ -1,30 +1,30 @@ {% include 'header.sql.jinja' %} -select - sum(ws_ext_discount_amt) as "Excess Discount Amount" -from - {{web_sales}} - ,{{item}} +select + sum(ws_ext_discount_amt) as "Excess Discount Amount" +from + {{web_sales}} + ,{{item}} ,{{date_dim}} where -i_manufact_id = 269 -and i_item_sk = ws_item_sk -and d_date between '1998-03-18'::date and - (cast('1998-03-18' as date) + interval '90' day)::date -and d_date_sk = ws_sold_date_sk -and ws_ext_discount_amt - > ( - SELECT - 1.3::numeric * avg(ws_ext_discount_amt) - FROM - {{web_sales}} +i_manufact_id = 356 +and i_item_sk = ws_item_sk +and d_date between '2001-03-12'::date and + (cast('2001-03-12' as date) + interval '90' day)::date +and d_date_sk = ws_sold_date_sk +and ws_ext_discount_amt + > ( + SELECT + 1.3::numeric * avg(ws_ext_discount_amt) + FROM + {{web_sales}} ,{{date_dim}} - WHERE - ws_item_sk = i_item_sk - and d_date between '1998-03-18'::date and - (cast('1998-03-18' as date) + interval '90' day)::date - and d_date_sk = ws_sold_date_sk - ) + WHERE + ws_item_sk = i_item_sk + and d_date between '2001-03-12'::date and + (cast('2001-03-12' as date) + interval '90' day)::date + and d_date_sk = ws_sold_date_sk + ) order by sum(ws_ext_discount_amt) limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q93.sql b/ydb/library/benchmarks/queries/tpcds/pg/q93.sql index a0a918892863..5c89e8969132 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q93.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q93.sql @@ -11,7 +11,7 @@ select ss_customer_sk and sr_ticket_number = ss_ticket_number) ,{{reason}} where sr_reason_sk = r_reason_sk - and r_reason_desc = 'Did not like the warranty') t + and r_reason_desc = 'reason 66') t group by ss_customer_sk order by sumsales, ss_customer_sk limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q94.sql b/ydb/library/benchmarks/queries/tpcds/pg/q94.sql index bdef983f11df..c9fdefc2d8ea 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q94.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q94.sql @@ -1,6 +1,6 @@ {% include 'header.sql.jinja' %} -select +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" @@ -10,11 +10,11 @@ from ,{{customer_address}} ,{{web_site}} where - d_date between '1999-5-01'::date and - (cast('1999-5-01' as date) + interval '60' day)::date + d_date between '1999-4-01'::date and + (cast('1999-4-01' as date) + interval '60' day)::date and ws1.ws_ship_date_sk = d_date_sk and ws1.ws_ship_addr_sk = ca_address_sk -and ca_state = 'TX' +and ca_state = 'NE' and ws1.ws_web_site_sk = web_site_sk and web_company_name = 'pri' and exists (select * diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q95.sql b/ydb/library/benchmarks/queries/tpcds/pg/q95.sql index 1c5b2c96f3f6..70598d190e6f 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q95.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q95.sql @@ -5,7 +5,7 @@ with ws_wh as from {{web_sales}} ws1,{{web_sales}} ws2 where ws1.ws_order_number = ws2.ws_order_number and ws1.ws_warehouse_sk <> ws2.ws_warehouse_sk) - select + 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" @@ -15,11 +15,11 @@ from ,{{customer_address}} ,{{web_site}} where - d_date between '1999-5-01'::date and - (cast('1999-5-01' as date) + interval '60' day)::date + d_date between '2002-4-01'::date and + (cast('2002-4-01' as date) + interval '60' day)::date and ws1.ws_ship_date_sk = d_date_sk and ws1.ws_ship_addr_sk = ca_address_sk -and ca_state = 'TX' +and ca_state = 'AL' and ws1.ws_web_site_sk = web_site_sk and web_company_name = 'pri' and ws1.ws_order_number in (select ws_order_number diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q96.sql b/ydb/library/benchmarks/queries/tpcds/pg/q96.sql index 073f8a6a50be..687c446e835b 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q96.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q96.sql @@ -1,15 +1,15 @@ {% include 'header.sql.jinja' %} -select count(*) +select count(*) from {{store_sales}} - ,{{household_demographics}} + ,{{household_demographics}} ,{{time_dim}}, {{store}} -where ss_sold_time_sk = time_dim.t_time_sk - and ss_hdemo_sk = household_demographics.hd_demo_sk +where ss_sold_time_sk = time_dim.t_time_sk + and ss_hdemo_sk = household_demographics.hd_demo_sk and ss_store_sk = s_store_sk - and time_dim.t_hour = 8 + and time_dim.t_hour = 16 and time_dim.t_minute >= 30 - and household_demographics.hd_dep_count = 5 + and household_demographics.hd_dep_count = 6 and store.s_store_name = 'ese' order by count(*) limit 100; diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q97.sql b/ydb/library/benchmarks/queries/tpcds/pg/q97.sql index f59bc66f2aa6..d4e0742b2332 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q97.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q97.sql @@ -5,7 +5,7 @@ select ss_customer_sk customer_sk ,ss_item_sk item_sk from {{store_sales}},{{date_dim}} where ss_sold_date_sk = d_date_sk - and d_month_seq between 1212 and 1212 + 11 + and d_month_seq between 1190 and 1190 + 11 group by ss_customer_sk ,ss_item_sk), csci as( @@ -13,7 +13,7 @@ csci as( ,cs_item_sk item_sk from {{catalog_sales}},{{date_dim}} where cs_sold_date_sk = d_date_sk - and d_month_seq between 1212 and 1212 + 11 + and d_month_seq between 1190 and 1190 + 11 group by cs_bill_customer_sk ,cs_item_sk) select sum(case when ssci.customer_sk is not null and csci.customer_sk is null then 1 else 0 end) store_only diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q98.sql b/ydb/library/benchmarks/queries/tpcds/pg/q98.sql index ba27486c674f..a0b8bd219cb9 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q98.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q98.sql @@ -1,30 +1,30 @@ {% include 'header.sql.jinja' %} select i_item_id - ,i_item_desc - ,i_category - ,i_class + ,i_item_desc + ,i_category + ,i_class ,i_current_price - ,sum(ss_ext_sales_price) as itemrevenue + ,sum(ss_ext_sales_price) as itemrevenue ,sum(ss_ext_sales_price)*100::numeric/sum(sum(ss_ext_sales_price)) over (partition by i_class) as revenueratio -from +from {{store_sales}} - ,{{item}} + ,{{item}} ,{{date_dim}} -where - ss_item_sk = i_item_sk - and i_category in ('Jewelry', 'Sports', 'Books') +where + ss_item_sk = i_item_sk + and i_category in ('Home', 'Sports', 'Men') 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' day)::date -group by + and d_date between cast('2002-01-05' as date) + and (cast('2002-01-05' as date) + interval '30' day)::date +group by i_item_id - ,i_item_desc + ,i_item_desc ,i_category ,i_class ,i_current_price -order by +order by i_category ,i_class ,i_item_id diff --git a/ydb/library/benchmarks/queries/tpcds/pg/q99.sql b/ydb/library/benchmarks/queries/tpcds/pg/q99.sql index 2abe25c5a3fa..2ffc2e97970d 100644 --- a/ydb/library/benchmarks/queries/tpcds/pg/q99.sql +++ b/ydb/library/benchmarks/queries/tpcds/pg/q99.sql @@ -1,17 +1,17 @@ {% include 'header.sql.jinja' %} -select +select 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" - ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and - (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" - ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and - (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk <= 30 ) then 1 else 0 end) as "30 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 30) and + (cs_ship_date_sk - cs_sold_date_sk <= 60) then 1 else 0 end ) as "31-60 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 60) and + (cs_ship_date_sk - cs_sold_date_sk <= 90) then 1 else 0 end) as "61-90 days" ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 90) and - (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" - ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" + (cs_ship_date_sk - cs_sold_date_sk <= 120) then 1 else 0 end) as "91-120 days" + ,sum(case when (cs_ship_date_sk - cs_sold_date_sk > 120) then 1 else 0 end) as ">120 days" from {{catalog_sales}} ,{{warehouse}} @@ -19,7 +19,7 @@ from ,{{call_center}} ,{{date_dim}} where - d_month_seq between 1212 and 1212 + 11 + d_month_seq between 1178 and 1178 + 11 and cs_ship_date_sk = d_date_sk and cs_warehouse_sk = w_warehouse_sk and cs_ship_mode_sk = sm_ship_mode_sk