You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
567 B

--begin q15
-- $ID$
-- TPC-H/TPC-R Top Supplier Query (Q15)
-- Variant A
-- Approved February 1998
:x
:o
with revenue (supplier_no, total_revenue) as (
select
l_suppkey,
sum(l_extendedprice * (1-l_discount))
from
tpch.lineitem
where
l_shipdate >= date ':1'
and l_shipdate < ADD_MONTHS(date':1', 3)
group by
l_suppkey
)
select
s_suppkey,
s_name,
s_address,
s_phone,
total_revenue
from
tpch.supplier,
revenue
where
s_suppkey = supplier_no
and total_revenue = (
select
max(total_revenue)
from
revenue
)
order by
s_suppkey;