33 lines
499 B
SQL
33 lines
499 B
SQL
-- $ID$
|
|
-- TPC-H/TPC-R Top Supplier Query (Q15)
|
|
-- Functional Query Definition
|
|
-- Approved February 1998
|
|
with revenue (supplier_no, total_revenue) as
|
|
(
|
|
select
|
|
l_suppkey,
|
|
sum(l_extendedprice * (1 - l_discount))
|
|
from
|
|
lineitem
|
|
where
|
|
l_shipdate >= date '1996-01-01'
|
|
and l_shipdate < date '1996-01-01' + interval '3 month'
|
|
group by
|
|
l_suppkey
|
|
)
|
|
select
|
|
s_suppkey,
|
|
s_name,
|
|
s_address,
|
|
s_phone,
|
|
total_revenue
|
|
from
|
|
supplier,
|
|
revenue
|
|
where
|
|
s_suppkey = supplier_no
|
|
order by
|
|
s_suppkey
|
|
;
|
|
|