-
Notifications
You must be signed in to change notification settings - Fork 446
/
q20.sql
34 lines (34 loc) · 907 Bytes
/
q20.sql
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
SELECT
s_name,
s_address
FROM
supplier,
nation
WHERE
s_suppkey IN (
SELECT
ps_suppkey
FROM
partsupp
WHERE
ps_partkey IN (
SELECT
p_partkey
FROM
part
WHERE
p_name LIKE 'forest%')
AND ps_availqty > (
SELECT
0.5 * sum(l_quantity)
FROM
lineitem
WHERE
l_partkey = ps_partkey
AND l_suppkey = ps_suppkey
AND l_shipdate >= date'1994-01-01'
AND l_shipdate < date'1994-01-01' + interval 1 year))
AND s_nationkey = n_nationkey
AND n_name = 'CANADA'
ORDER BY
s_name;