diff options
author | udovichenko-r <udovichenko-r@yandex-team.com> | 2024-11-19 14:58:38 +0300 |
---|---|---|
committer | udovichenko-r <udovichenko-r@yandex-team.com> | 2024-11-19 15:16:27 +0300 |
commit | 24521403b1c44303e043ba540c09b1fe991c7474 (patch) | |
tree | 341d1e7206bc7c143d04d2d96f05b6dc0655606d /yql/essentials/tests/sql/suites/tpch/q8.sql | |
parent | 72b3cd51dc3fb9d16975d353ea82fd85701393cc (diff) | |
download | ydb-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/tpch/q8.sql')
-rw-r--r-- | yql/essentials/tests/sql/suites/tpch/q8.sql | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/suites/tpch/q8.sql b/yql/essentials/tests/sql/suites/tpch/q8.sql new file mode 100644 index 0000000000..855813a06e --- /dev/null +++ b/yql/essentials/tests/sql/suites/tpch/q8.sql @@ -0,0 +1,110 @@ + +-- TPC-H/TPC-R National Market Share Query (Q8) +-- TPC TPC-H Parameter Substitution (Version 2.17.2 build 0) +-- using 1680793381 as a seed to the RNG + +$join1 = ( +select + l.l_extendedprice * (1 - l.l_discount) as volume, + l.l_suppkey as l_suppkey, + l.l_orderkey as l_orderkey +from + plato.part as p +join + plato.lineitem as l +on + p.p_partkey = l.l_partkey +where + p.p_type = 'ECONOMY PLATED COPPER' +); +$join2 = ( +select + j.volume as volume, + j.l_orderkey as l_orderkey, + s.s_nationkey as s_nationkey +from + $join1 as j +join + plato.supplier as s +on + s.s_suppkey = j.l_suppkey +); +$join3 = ( +select + j.volume as volume, + j.l_orderkey as l_orderkey, + n.n_name as nation +from + $join2 as j +join + plato.nation as n +on + n.n_nationkey = j.s_nationkey +); +$join4 = ( +select + j.volume as volume, + j.nation as nation, + DateTime::GetYear(cast(o.o_orderdate as Timestamp)) as o_year, + o.o_custkey as o_custkey +from + $join3 as j +join + plato.orders as o +on + o.o_orderkey = j.l_orderkey +where cast(cast(o_orderdate as Timestamp) as Date) between Date('1995-01-01') and Date('1996-12-31') +); +$join5 = ( +select + j.volume as volume, + j.nation as nation, + j.o_year as o_year, + c.c_nationkey as c_nationkey +from + $join4 as j +join + plato.customer as c +on + c.c_custkey = j.o_custkey +); +$join6 = ( +select + j.volume as volume, + j.nation as nation, + j.o_year as o_year, + n.n_regionkey as n_regionkey +from + $join5 as j +join + plato.nation as n +on + n.n_nationkey = j.c_nationkey +); +$join7 = ( +select + j.volume as volume, + j.nation as nation, + j.o_year as o_year +from + $join6 as j +join + plato.region as r +on + r.r_regionkey = j.n_regionkey +where + r.r_name = 'AFRICA' +); + +select + o_year, + sum(case + when nation = 'MOZAMBIQUE' then volume + else 0 + end) / sum(volume) as mkt_share +from + $join7 as all_nations +group by + o_year +order by + o_year; |