diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
commit | 31773f157bf8164364649b5f470f52dece0a4317 (patch) | |
tree | 33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /yql/essentials/tests/sql/suites/pg-tpcds/q39.sql | |
parent | 2c7938962d8689e175574fc1e817c05049f27905 (diff) | |
parent | eff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff) | |
download | ydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz |
Merge branch 'rightlib' into mergelibs-241120-1113
Diffstat (limited to 'yql/essentials/tests/sql/suites/pg-tpcds/q39.sql')
-rw-r--r-- | yql/essentials/tests/sql/suites/pg-tpcds/q39.sql | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/pg-tpcds/q39.sql b/yql/essentials/tests/sql/suites/pg-tpcds/q39.sql new file mode 100644 index 0000000000..c877082142 --- /dev/null +++ b/yql/essentials/tests/sql/suites/pg-tpcds/q39.sql @@ -0,0 +1,57 @@ +--!syntax_pg +--TPC-DS Q39 + +-- start query 1 in stream 0 using template ../query_templates/query39.tpl +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0::numeric then null::numeric else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from plato.inventory + ,plato.item + ,plato.warehouse + ,plato.date_dim + 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 + 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 + ,inv2.w_warehouse_sk as inv2_w_warehouse_sk,inv2.i_item_sk as inv2_i_item_sk,inv2.d_moy as inv2_d_moy,inv2.mean as inv2_mean, inv2.cov as inv2_cov +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 +order by inv1_w_warehouse_sk,inv1_i_item_sk,inv1_d_moy,inv1_mean,inv1_cov + ,inv2_d_moy,inv2_mean, inv2_cov +; +with inv as +(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stdev,mean, case mean when 0::numeric then null::numeric else stdev/mean end cov + from(select w_warehouse_name,w_warehouse_sk,i_item_sk,d_moy + ,stddev_samp(inv_quantity_on_hand) stdev,avg(inv_quantity_on_hand) mean + from plato.inventory + ,plato.item + ,plato.warehouse + ,plato.date_dim + 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 + 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 + ,inv2.w_warehouse_sk as inv2_w_warehouse_sk,inv2.i_item_sk as inv2_i_item_sk,inv2.d_moy as inv2_d_moy,inv2.mean as inv2_mean, inv2.cov as inv2_cov +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.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 +; + +-- end query 1 in stream 0 using template ../query_templates/query39.tpl |