aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/pg-tpch/q03.sql
blob: fd34b86d2bacc5b599867cb4d853e8b9944d30d7 (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
--!syntax_pg
--TPC-H Q3


select
l_orderkey, 
sum(l_extendedprice*(1::numeric-l_discount)) as revenue,
o_orderdate, 
o_shippriority
from 
plato."customer", 
plato."orders", 
plato."lineitem"
where 
c_mktsegment = 'BUILDING'
and c_custkey = o_custkey
and l_orderkey = o_orderkey
and o_orderdate < date '1995-03-15'
and l_shipdate > date '1995-03-15'
group by 
l_orderkey, 
o_orderdate, 
o_shippriority
order by 
revenue desc, 
o_orderdate
limit 10;