Skip to content

Commit 2fe5ad9

Browse files
authored
Merge pull request #7601 from xudong963/fix_q15
fix: Fix wrong tpch q15 sql
2 parents 1d0b42a + fb63f2b commit 2fe5ad9

File tree

2 files changed

+28
-40
lines changed

2 files changed

+28
-40
lines changed
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
FRANCE GERMANY 1995 4637235.15
2-
FRANCE GERMANY 1996 5224779.573
3-
GERMANY FRANCE 1995 6232818.703
4-
GERMANY FRANCE 1996 5557312.112
1+
677 Supplier#000000677 8mhrffG7D2WJBSQbOGstQ 23-290-639-3315 1614410.29
Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
1+
with revenue as (
2+
select
3+
l_suppkey as supplier_no,
4+
truncate(sum(l_extendedprice * (1 - l_discount)), 2) as total_revenue
5+
from
6+
lineitem
7+
where
8+
l_shipdate >= to_date ('1996-01-01')
9+
and l_shipdate < to_date ('1996-04-01')
10+
group by
11+
l_suppkey)
112

213
select
3-
supp_nation,
4-
cust_nation,
5-
l_year,
6-
truncate(sum(volume),3) as revenue
14+
s_suppkey,
15+
s_name,
16+
s_address,
17+
s_phone,
18+
total_revenue
719
from
8-
(
9-
select
10-
n1.n_name as supp_nation,
11-
n2.n_name as cust_nation,
12-
extract(year from l_shipdate) as l_year,
13-
l_extendedprice * (1 - l_discount) as volume
14-
from
15-
orders,
16-
lineitem,
17-
supplier,
18-
customer,
19-
nation n1,
20-
nation n2
21-
where
22-
s_suppkey = l_suppkey
23-
and o_orderkey = l_orderkey
24-
and c_custkey = o_custkey
25-
and s_nationkey = n1.n_nationkey
26-
and c_nationkey = n2.n_nationkey
27-
and (
28-
(n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY')
29-
or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE')
30-
)
31-
and l_shipdate between to_date('1995-01-01') and to_date('1996-12-31')
32-
) as shipping
33-
group by
34-
supp_nation,
35-
cust_nation,
36-
l_year
20+
supplier,
21+
revenue
22+
where
23+
s_suppkey = supplier_no
24+
and total_revenue = (
25+
select
26+
max(total_revenue)
27+
from
28+
revenue
29+
)
3730
order by
38-
supp_nation,
39-
cust_nation,
40-
l_year;
31+
s_suppkey;

0 commit comments

Comments
 (0)