-
Notifications
You must be signed in to change notification settings - Fork 446
/
q15.sql
35 lines (35 loc) · 921 Bytes
/
q15.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
35
SELECT
s_suppkey,
s_name,
s_address,
s_phone,
total_revenue
FROM
supplier,
(
SELECT
l_suppkey AS supplier_no,
sum(l_extendedprice * (1 - l_discount)) AS total_revenue
FROM
lineitem
WHERE
l_shipdate >= date'1996-01-01' AND l_shipdate < date'1996-01-01' + interval 3 month
GROUP BY
supplier_no) revenue0
WHERE
s_suppkey = supplier_no
AND total_revenue = (
SELECT
max(total_revenue)
FROM (
SELECT
l_suppkey AS supplier_no,
sum(l_extendedprice * (1 - l_discount)) AS total_revenue
FROM
lineitem
WHERE
l_shipdate >= date'1996-01-01' AND l_shipdate < date'1996-01-01' + interval 3 month
GROUP BY
supplier_no) revenue1)
ORDER BY
s_suppkey;