# name: benchmark/tpch/union/q01_union.benchmark # description: Union of separate tables into a single aggregate # group: [union] include benchmark/tpch/tpch_load.benchmark.in name Lineitem Union Q01 group union subgroup tpch run SELECT l_returnflag, l_linestatus, sum(l_quantity) AS sum_qty, sum(l_extendedprice) AS sum_base_price, sum(l_extendedprice * (1 - l_discount)) AS sum_disc_price, sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, avg(l_quantity) AS avg_qty, avg(l_extendedprice) AS avg_price, avg(l_discount) AS avg_disc, count(*) AS count_order FROM ( SELECT * FROM lineitem WHERE l_shipdate <= DATE '1990-09-02' UNION ALL SELECT * FROM lineitem WHERE l_shipdate > DATE '1990-09-02' AND l_shipdate <= DATE '1992-09-02' UNION ALL SELECT * FROM lineitem WHERE l_shipdate > DATE '1992-09-02' AND l_shipdate <= DATE '1994-09-02' UNION ALL SELECT * FROM lineitem WHERE l_shipdate > DATE '1994-09-02' AND l_shipdate <= DATE '1996-09-02' UNION ALL SELECT * FROM lineitem WHERE l_shipdate > DATE '1996-09-02' AND l_shipdate <= DATE '1998-09-02' ) lineitem GROUP BY l_returnflag, l_linestatus ORDER BY l_returnflag, l_linestatus; result extension/tpch/dbgen/answers/sf1/q01.csv sf=1