arcs / tasks /readable /010 /task_readable.md
yanlinf's picture
Release ARCS dataset
1fb4e2d verified
|
Raw History Blame Contribute Delete
745 Bytes

Task: 010

Database: retails

Question

Find the regions associated with the highest-value order in the car industry.

Gold Query

WITH automobile_orders AS (
SELECT o.o_orderkey, o.o_totalprice, c.c_nationkey
FROM orders o
JOIN customer c ON o.o_custkey = c.c_custkey
WHERE c.c_mktsegment = 'AUTOMOBILE'
),
max_order AS (
SELECT MAX(o_totalprice) as max_price
FROM automobile_orders
)
SELECT DISTINCT r.r_regionkey, r.r_name
FROM automobile_orders ao
JOIN max_order mo ON ao.o_totalprice = mo.max_price
JOIN nation n ON ao.c_nationkey = n.n_nationkey
JOIN region r ON n.n_regionkey = r.r_regionkey;

Execution Result:

r_regionkey r_name
3 EUROPE

1 rows