aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/pg-tpch/q18.sql
blob: 0c3289123703e210c53082ddda95dc09101c356a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--!syntax_pg
--ignore runonopt plan diff
--TPC-H Q18


select 
c_name,
c_custkey, 
o_orderkey,
o_orderdate,
o_totalprice,
sum(l_quantity)
from 
plato."customer",
plato."orders",
plato."lineitem"
where 
o_orderkey in (
select
l_orderkey
from
plato."lineitem"
group by 
l_orderkey having 
sum(l_quantity) > 300::numeric
)
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;