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.
53 lines
833 B
53 lines
833 B
3 years ago
|
--begin q02
|
||
|
-- $ID$
|
||
|
-- TPC-H/TPC-R Minimum Cost Supplier Query (Q2)
|
||
|
-- Functional Query Definition
|
||
|
-- Approved February 1998
|
||
|
:x
|
||
|
:o
|
||
|
select
|
||
|
s_acctbal,
|
||
|
s_name,
|
||
|
n_name,
|
||
|
p_partkey,
|
||
|
p_mfgr,
|
||
|
s_address,
|
||
|
s_phone,
|
||
|
s_comment
|
||
|
from
|
||
|
tpch.part,
|
||
|
tpch.supplier,
|
||
|
tpch.partsupp,
|
||
|
tpch.nation,
|
||
|
tpch.region
|
||
|
where
|
||
|
p_partkey = ps_partkey
|
||
|
and s_suppkey = ps_suppkey
|
||
|
and p_size = :1
|
||
|
and p_type like '%:2'
|
||
|
and s_nationkey = n_nationkey
|
||
|
and n_regionkey = r_regionkey
|
||
|
and r_name = ':3'
|
||
|
and ps_supplycost = (
|
||
|
select
|
||
|
min(ps_supplycost)
|
||
|
from
|
||
|
tpch.partsupp,
|
||
|
tpch.supplier,
|
||
|
tpch.nation,
|
||
|
tpch.region
|
||
|
where
|
||
|
p_partkey = ps_partkey
|
||
|
and s_suppkey = ps_suppkey
|
||
|
and s_nationkey = n_nationkey
|
||
|
and n_regionkey = r_regionkey
|
||
|
and r_name = ':3'
|
||
|
)
|
||
|
order by
|
||
|
s_acctbal desc,
|
||
|
n_name,
|
||
|
s_name,
|
||
|
p_partkey;
|
||
|
:n 100;
|
||
|
--end q02
|