mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 06:18:17 +00:00
35 lines
486 B
SQL
35 lines
486 B
SQL
-- using default substitutions
|
|
|
|
|
|
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) > 300
|
|
)
|
|
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;
|