aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/pg-tpcds/q83.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/q83.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/q83.sql')
-rw-r--r--yql/essentials/tests/sql/suites/pg-tpcds/q83.sql70
1 files changed, 70 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/pg-tpcds/q83.sql b/yql/essentials/tests/sql/suites/pg-tpcds/q83.sql
new file mode 100644
index 0000000000..0801e9902c
--- /dev/null
+++ b/yql/essentials/tests/sql/suites/pg-tpcds/q83.sql
@@ -0,0 +1,70 @@
+--!syntax_pg
+--TPC-DS Q83
+
+-- start query 1 in stream 0 using template ../query_templates/query83.tpl
+with sr_items as
+ (select i_item_id item_id,
+ sum(sr_return_quantity) sr_item_qty
+ from plato.store_returns,
+ plato.item,
+ plato.date_dim
+ where sr_item_sk = i_item_sk
+ and d_date in
+ (select d_date
+ from plato.date_dim
+ where d_week_seq in
+ (select d_week_seq
+ from plato.date_dim
+ where d_date in ('1998-01-02'::date,'1998-10-15'::date,'1998-11-10'::date)))
+ and sr_returned_date_sk = d_date_sk
+ group by i_item_id),
+ cr_items as
+ (select i_item_id item_id,
+ sum(cr_return_quantity) cr_item_qty
+ from plato.catalog_returns,
+ plato.item,
+ plato.date_dim
+ where cr_item_sk = i_item_sk
+ and d_date in
+ (select d_date
+ from plato.date_dim
+ where d_week_seq in
+ (select d_week_seq
+ from plato.date_dim
+ where d_date in ('1998-01-02'::date,'1998-10-15'::date,'1998-11-10'::date)))
+ and cr_returned_date_sk = d_date_sk
+ group by i_item_id),
+ wr_items as
+ (select i_item_id item_id,
+ sum(wr_return_quantity) wr_item_qty
+ from plato.web_returns,
+ plato.item,
+ plato.date_dim
+ where wr_item_sk = i_item_sk
+ and d_date in
+ (select d_date
+ from plato.date_dim
+ where d_week_seq in
+ (select d_week_seq
+ from plato.date_dim
+ where d_date in ('1998-01-02'::date,'1998-10-15'::date,'1998-11-10'::date)))
+ and wr_returned_date_sk = d_date_sk
+ group by i_item_id)
+ select sr_items.item_id
+ ,sr_item_qty
+ ,sr_item_qty::numeric/(sr_item_qty+cr_item_qty+wr_item_qty)::numeric/3.0::numeric * 100::numeric sr_dev
+ ,cr_item_qty
+ ,cr_item_qty::numeric/(sr_item_qty+cr_item_qty+wr_item_qty)::numeric/3.0::numeric * 100::numeric cr_dev
+ ,wr_item_qty
+ ,wr_item_qty::numeric/(sr_item_qty+cr_item_qty+wr_item_qty)::numeric/3.0::numeric * 100::numeric wr_dev
+ ,(sr_item_qty+cr_item_qty+wr_item_qty)::numeric/3.0::numeric average
+ from sr_items
+ ,cr_items
+ ,wr_items
+ where sr_items.item_id=cr_items.item_id
+ and sr_items.item_id=wr_items.item_id
+ order by sr_items.item_id
+ ,sr_item_qty
+ limit 100;
+
+-- end query 1 in stream 0 using template ../query_templates/query83.tpl