arcs / tasks /readable /002 /task_readable.md
yanlinf's picture
Release ARCS dataset
1fb4e2d verified
|
Raw History Blame Contribute Delete
1.01 kB
# Task: 002
**Database:** retails
## Question
Count the number of suppliers that offer both air and rail shipping in America.
## Gold Query
```sql
WITH usa_suppliers_with_air AS (
SELECT DISTINCT l.l_suppkey
FROM lineitem l
JOIN orders o ON l.l_orderkey = o.o_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
JOIN region r ON n.n_regionkey = r.r_regionkey
WHERE r.r_name = 'AMERICA'
AND l.l_shipmode = 'AIR'
),
usa_suppliers_with_rail AS (
SELECT DISTINCT l.l_suppkey
FROM lineitem l
JOIN orders o ON l.l_orderkey = o.o_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
JOIN region r ON n.n_regionkey = r.r_regionkey
WHERE r.r_name = 'AMERICA'
AND l.l_shipmode = 'RAIL'
)
SELECT COUNT(*) AS supplier_count
FROM usa_suppliers_with_air a
JOIN usa_suppliers_with_rail r ON a.l_suppkey = r.l_suppkey;
```
**Execution Result:**
| supplier_count |
|------------------|
| 10000 |
*1 rows*