mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-09 22:42:57 +00:00
40 lines
542 B
SQL
40 lines
542 B
SQL
-- $ID$
|
|
-- TPC-H/TPC-R Large Volume Customer Query (Q18)
|
|
-- Function Query Definition
|
|
-- Approved February 1998
|
|
|
|
|
|
select
|
|
c_name,
|
|
c_custkey,
|
|
o_orderkey,
|
|
o_orderdate,
|
|
o_totalprice,
|
|
sum(l_quantity)
|
|
from
|
|
customer,
|
|
orders,
|
|
lineitem
|
|
where
|
|
o_orderkey in (
|
|
select
|
|
l_orderkey
|
|
from
|
|
lineitem
|
|
group by
|
|
l_orderkey having
|
|
sum(l_quantity) > 315
|
|
)
|
|
and c_custkey = o_custkey
|
|
and o_orderkey = l_orderkey
|
|
group by
|
|
c_name,
|
|
c_custkey,
|
|
o_orderkey,
|
|
o_orderdate,
|
|
o_totalprice
|
|
order by
|
|
o_totalprice desc,
|
|
o_orderdate
|
|
limit 100;
|