|
Download tasks/readable/025/task_readable.md from megagonlabs/arcs: direct link, hf CLI and curl.
- Browser
- Download file 2.29 kB
-
https://huggingface.co/datasets/megagonlabs/arcs/resolve/main/tasks/readable/025/task_readable.md
- Command line
-
hf download hf://datasets/megagonlabs/arcs/tasks/readable/025/task_readable.md
-
curl -L -o task_readable.md https://huggingface.co/datasets/megagonlabs/arcs/resolve/main/tasks/readable/025/task_readable.md
2.29 kB
Task: 025
Database: retails
Question
For each manufacturer, find top N products with highest revenue from sales in America. Return the manufacturer, product, and revenue.
Gold Query
WITH america_revenue AS (
SELECT
p.p_mfgr,
p.p_partkey,
p.p_name,
SUM(l.l_extendedprice) AS revenue,
RANK() OVER (PARTITION BY p.p_mfgr ORDER BY SUM(l.l_extendedprice) DESC) AS rn
FROM lineitem l
JOIN part p ON l.l_partkey = p.p_partkey
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
WHERE n.n_name = 'UNITED STATES'
GROUP BY p.p_mfgr, p.p_partkey, p.p_name
)
SELECT p_mfgr, p_partkey, p_name, revenue
FROM america_revenue
WHERE rn <= :top_n
ORDER BY p_mfgr, revenue DESC;
Execution Result:
| p_mfgr | p_partkey | p_name | revenue |
|---|---|---|---|
| Manufacturer#1 | 192229 | beige mint lavender light mint | 350123.3 |
| Manufacturer#1 | 37637 | powder papaya azure blush gainsboro | 341694.71 |
| Manufacturer#1 | 199745 | azure black firebrick green rosy | 332053.2 |
| Manufacturer#2 | 108984 | linen chocolate sky misty linen | 370694.28 |
| Manufacturer#2 | 896 | ivory thistle wheat lavender bisque | 345002.88 |
| Manufacturer#2 | 178779 | pale peach cream orchid pale | 334398.6 |
| Manufacturer#3 | 62925 | azure puff navy olive sky | 402126.96 |
| Manufacturer#3 | 192905 | honeydew orchid dodger floral royal | 385594.7 |
| Manufacturer#3 | 151855 | wheat goldenrod ghost floral brown | 364208.35 |
| Manufacturer#4 | 76992 | slate medium powder antique goldenrod | 354418.2 |
| Manufacturer#4 | 185839 | powder ghost sienna magenta wheat | 338770.08 |
| Manufacturer#4 | 186960 | lemon blanched turquoise blush brown | 335701.44 |
| Manufacturer#5 | 97943 | burnished lawn tomato magenta turquoise | 399833.64 |
| Manufacturer#5 | 150952 | slate tomato bisque linen orange | 372548.7 |
| Manufacturer#5 | 169945 | antique thistle salmon steel indian | 354629.44 |
15 rows