/* { "qid": "023", "task_type": "ambig", "has_intended_resolution": true, "language": "SQLite", "db": "retails", "question": "For each supplier with ID from 1 to 100, determine the total amount owed to them.", "gold_ambiguity_points": [ { "id": "A", "phrase": "total amount owed", "type": "finite", "ambiguity_type": "semantic_computation", "interpretations": [ "balance in the supplier's account", "value of open line items", "value of line items in unfinished orders" ], "intended_interpretation_idx": 1 } ], "gold_intended_query_id": "GQRY-A.1", "extra_info": {} } */ ----- START OF GOLD QUERY `GQRY-A.0` ----- /* { "id": "GQRY-A.0", "parameter_names": [], "parameter_values": {}, "other_exec_results": [], "required_columns": [ 0, 2 ], "required_sorted": false, "extra_info": { "ambiguity_resolution": { "[A] total amount owed": "balance in the supplier's account" } } } */ SELECT s_suppkey, s_name, s_acctbal AS total_amount_owed FROM supplier WHERE s_suppkey BETWEEN 1 AND 100; /* EXEC RESULT s_suppkey s_name total_amount_owed 1 Supplier#000000001 3082.86 2 Supplier#000000002 3009.73 3 Supplier#000000003 9159.78 4 Supplier#000000004 9846.01 5 Supplier#000000005 -74.94 ... TRUNCATED ... 96 Supplier#000000096 -668.13 97 Supplier#000000097 3229.29 98 Supplier#000000098 150.70 99 Supplier#000000099 2074.00 100 Supplier#000000100 1026.74 */ ----- END OF GOLD QUERY ----- ----- START OF GOLD QUERY `GQRY-A.1` ----- /* { "id": "GQRY-A.1", "parameter_names": [], "parameter_values": {}, "other_exec_results": [], "required_columns": [ 0, 2 ], "required_sorted": false, "extra_info": { "ambiguity_resolution": { "[A] total amount owed": "value of open line items" } } } */ SELECT s.s_suppkey, s.s_name, COALESCE(SUM(l.l_quantity * ps.ps_supplycost), 0) AS total_amount_owed FROM supplier s LEFT JOIN lineitem l ON s.s_suppkey = l.l_suppkey AND l.l_linestatus = 'O' LEFT JOIN partsupp ps ON l.l_partkey = ps.ps_partkey AND l.l_suppkey = ps.ps_suppkey WHERE s.s_suppkey BETWEEN 1 AND 100 GROUP BY s.s_suppkey, s.s_name; /* EXEC RESULT s_suppkey s_name total_amount_owed 1 Supplier#000000001 3997515.97 2 Supplier#000000002 3702069.16 3 Supplier#000000003 3821614.42 4 Supplier#000000004 4106842.46 5 Supplier#000000005 3237869.22 ... TRUNCATED ... 96 Supplier#000000096 3946293.81 97 Supplier#000000097 5186666.95 98 Supplier#000000098 4234214.40 99 Supplier#000000099 3389696.31 100 Supplier#000000100 2705119.05 */ ----- END OF GOLD QUERY ----- ----- START OF GOLD QUERY `GQRY-A.2` ----- /* { "id": "GQRY-A.2", "parameter_names": [], "parameter_values": {}, "other_exec_results": [], "required_columns": [ 0, 2 ], "required_sorted": false, "extra_info": { "ambiguity_resolution": { "[A] total amount owed": "value of line items in unfinished orders" } } } */ SELECT s.s_suppkey, s.s_name, COALESCE(SUM(l.l_quantity * ps.ps_supplycost), 0) AS total_amount_owed FROM supplier AS s LEFT JOIN lineitem AS l ON s.s_suppkey = l.l_suppkey LEFT JOIN partsupp AS ps ON l.l_partkey = ps.ps_partkey AND l.l_suppkey = ps.ps_suppkey LEFT JOIN orders AS o ON l.l_orderkey = o.o_orderkey AND o.o_orderstatus <> 'F' WHERE s.s_suppkey BETWEEN 1 AND 100 GROUP BY s.s_suppkey, s.s_name; /* EXEC RESULT s_suppkey s_name total_amount_owed 1 Supplier#000000001 6214813.11 2 Supplier#000000002 5173401.67 3 Supplier#000000003 5582552.23 4 Supplier#000000004 5775465.02 5 Supplier#000000005 4846809.88 ... TRUNCATED ... 96 Supplier#000000096 5815827.40 97 Supplier#000000097 7649457.28 98 Supplier#000000098 6310857.48 99 Supplier#000000099 5039484.14 100 Supplier#000000100 4159018.36 */ ----- END OF GOLD QUERY -----