Files
impala/testdata/workloads/tpch/queries/tpch-q8.test
ishaan 2b5df0c6ff [CDH5] Convert tpch schemas to decimal and change the queries where possible.
I used the following document for reference: http://www.tpc.org/tpch/spec/tpch2.1.0.pdf

Change-Id: Ic84db0628323c90e89552707f214bbb9fa2f2ae0
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3132
Reviewed-by: Ishaan Joshi <ishaan@cloudera.com>
Tested-by: jenkins
2014-07-08 14:51:43 -07:00

41 lines
959 B
Plaintext

====
---- QUERY: TPCH-Q8
# Q8 - National Market Share Query
# Modifications: Got rid of subquery, converted select from multiple tables to joins,
select
year(o_orderdate) as o_year,
sum(case
when n2.n_name = 'BRAZIL'
then l_extendedprice * (1 - l_discount)
else 0
end) / sum(l_extendedprice * (1 - l_discount)) as mkt_share
from lineitem l
join orders o
on (l_orderkey = o_orderkey)
join part p
on (p_partkey = l_partkey)
join supplier s
on (s_suppkey = l_suppkey)
join customer c
on (o_custkey = c_custkey)
join nation n1
on (c_nationkey = n1.n_nationkey)
join region r
on (n1.n_regionkey = r_regionkey)
join nation n2
on (s_nationkey = n2.n_nationkey)
where
r_name = 'AMERICA' and
o_orderdate >= '1995-01-01' and
o_orderdate < '1996-12-31' and
p_type = 'ECONOMY ANODIZED STEEL'
group by
o_year
order by
o_year
---- RESULTS
1995,0.0344
1996,0.0415
---- TYPES
int, decimal
====