arcs / tasks /readable /021 /task_readable.md
yanlinf's picture
Release ARCS dataset
1fb4e2d verified
|
Raw History Blame Contribute Delete
1.75 kB

Task: 021

Database: retails

Question

Find customers with high purchase quantities.

Gold Query

SELECT c.c_custkey, c.c_name, SUM(l.l_quantity) as total_quantity
FROM customer c
JOIN orders o ON c.c_custkey = o.o_custkey
JOIN lineitem l ON o.o_orderkey = l.l_orderkey
GROUP BY c.c_custkey, c.c_name
HAVING SUM(l.l_quantity) >= :quantity_threshold
ORDER BY total_quantity DESC;

Execution Result:

c_custkey c_name total_quantity
68513 Customer#000068513 3779
114308 Customer#000114308 3612
58421 Customer#000058421 3605
147472 Customer#000147472 3544
48853 Customer#000048853 3535
25862 Customer#000025862 3533
44167 Customer#000044167 3526
84203 Customer#000084203 3520
108451 Customer#000108451 3486
12581 Customer#000012581 3470
... ... ...
12931 Customer#000012931 2802
17203 Customer#000017203 2802
104228 Customer#000104228 2802
10780 Customer#000010780 2801
14912 Customer#000014912 2801
78145 Customer#000078145 2801
2648 Customer#000002648 2800
22985 Customer#000022985 2800
39151 Customer#000039151 2800
102176 Customer#000102176 2800

... truncated (351 rows total)