aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/pg-tpcds/q31.sql
diff options
context:
space:
mode:
authorudovichenko-r <udovichenko-r@yandex-team.com>2024-11-19 14:58:38 +0300
committerudovichenko-r <udovichenko-r@yandex-team.com>2024-11-19 15:16:27 +0300
commit24521403b1c44303e043ba540c09b1fe991c7474 (patch)
tree341d1e7206bc7c143d04d2d96f05b6dc0655606d /yql/essentials/tests/sql/suites/pg-tpcds/q31.sql
parent72b3cd51dc3fb9d16975d353ea82fd85701393cc (diff)
downloadydb-24521403b1c44303e043ba540c09b1fe991c7474.tar.gz
YQL-19206 Move contrib/ydb/library/yql/tests/sql/suites -> yql/essentials/tests/sql/suites
commit_hash:d0ef1f92b09c94db7c2408f946d2a4c62b603f00
Diffstat (limited to 'yql/essentials/tests/sql/suites/pg-tpcds/q31.sql')
-rw-r--r--yql/essentials/tests/sql/suites/pg-tpcds/q31.sql55
1 files changed, 55 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/pg-tpcds/q31.sql b/yql/essentials/tests/sql/suites/pg-tpcds/q31.sql
new file mode 100644
index 0000000000..7cc0cc6542
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/pg-tpcds/q31.sql
@@ -0,0 +1,55 @@
+--!syntax_pg
+--TPC-DS Q31
+
+-- start query 1 in stream 0 using template ../query_templates/query31.tpl
+with ss as
+ (select ca_county,d_qoy, d_year,sum(ss_ext_sales_price) as store_sales
+ from plato.store_sales,plato.date_dim,plato.customer_address
+ where ss_sold_date_sk = d_date_sk
+ and ss_addr_sk=ca_address_sk
+ group by ca_county,d_qoy, d_year),
+ ws as
+ (select ca_county,d_qoy, d_year,sum(ws_ext_sales_price) as web_sales
+ from plato.web_sales,plato.date_dim,plato.customer_address
+ 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
+ ss1.ca_county
+ ,ss1.d_year
+ ,ws2.web_sales/ws1.web_sales web_q1_q2_increase
+ ,ss2.store_sales/ss1.store_sales store_q1_q2_increase
+ ,ws3.web_sales/ws2.web_sales web_q2_q3_increase
+ ,ss3.store_sales/ss2.store_sales store_q2_q3_increase
+ from
+ ss ss1
+ ,ss ss2
+ ,ss ss3
+ ,ws ws1
+ ,ws ws2
+ ,ws ws3
+ where
+ ss1.d_qoy = 1
+ and ss1.d_year = 2000
+ and ss1.ca_county = ss2.ca_county
+ and ss2.d_qoy = 2
+ and ss2.d_year = 2000
+ and ss2.ca_county = ss3.ca_county
+ and ss3.d_qoy = 3
+ and ss3.d_year = 2000
+ and ss1.ca_county = ws1.ca_county
+ and ws1.d_qoy = 1
+ and ws1.d_year = 2000
+ and ws1.ca_county = ws2.ca_county
+ and ws2.d_qoy = 2
+ and ws2.d_year = 2000
+ 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
+ > 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
+ order by ss1.d_year;
+
+-- end query 1 in stream 0 using template ../query_templates/query31.tpl