arcs-bench / tasks /readable /001 /task_readable.sql
anon
Upload tasks/ folder for end-to-end loader reproducibility
02edc38
/*
{
"qid": "001",
"task_type": "ambig",
"has_intended_resolution": true,
"language": "SQLite",
"db": "retails",
"question": "Report the total revenue for each nation in 1995.",
"gold_ambiguity_points": [
{
"id": "A",
"phrase": "total revenue",
"type": "finite",
"ambiguity_type": "semantic_computation",
"interpretations": [
"before discount (Gross revenue)",
"after discount (Net revenue)"
],
"intended_interpretation_idx": 0
},
{
"id": "B",
"phrase": "total revenue",
"type": "finite",
"ambiguity_type": "semantic_computation",
"interpretations": [
"include returned items",
"exclude returned items"
],
"intended_interpretation_idx": 0
},
{
"id": "C",
"phrase": "for each nation",
"type": "finite",
"ambiguity_type": "semantic_table",
"interpretations": [
"for each customer nation",
"for each supplier nation"
],
"intended_interpretation_idx": 1
},
{
"id": "D",
"phrase": "in 1995",
"type": "finite",
"ambiguity_type": "semantic_column",
"interpretations": [
"order date in 1995",
"commitment date in 1995",
"shipment date in 1995",
"receipt date in 1995"
],
"intended_interpretation_idx": 3
}
],
"gold_intended_query_id": "GQRY-A.0-B.0-C.1-D.3",
"extra_info": {}
}
*/
----- START OF GOLD QUERY `GQRY-A.0-B.0-C.0-D.0` -----
/*
{
"id": "GQRY-A.0-B.0-C.0-D.0",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "order date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', o.o_orderdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.391923e+09
1 ARGENTINA 1.453863e+09
2 BRAZIL 1.381266e+09
3 CANADA 1.472857e+09
4 EGYPT 1.448095e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.326805e+09
21 VIETNAM 1.371851e+09
22 RUSSIA 1.413990e+09
23 UNITED KINGDOM 1.362103e+09
24 UNITED STATES 1.461729e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.0-C.0-D.1` -----
/*
{
"id": "GQRY-A.0-B.0-C.0-D.1",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "commitment date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_commitdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.382159e+09
1 ARGENTINA 1.467158e+09
2 BRAZIL 1.390410e+09
3 CANADA 1.474130e+09
4 EGYPT 1.432647e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.349162e+09
21 VIETNAM 1.377544e+09
22 RUSSIA 1.431568e+09
23 UNITED KINGDOM 1.365573e+09
24 UNITED STATES 1.460255e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.0-C.0-D.2` -----
/*
{
"id": "GQRY-A.0-B.0-C.0-D.2",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "shipment date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_shipdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.374909e+09
1 ARGENTINA 1.475768e+09
2 BRAZIL 1.389602e+09
3 CANADA 1.475634e+09
4 EGYPT 1.432775e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.347251e+09
21 VIETNAM 1.387260e+09
22 RUSSIA 1.430246e+09
23 UNITED KINGDOM 1.372975e+09
24 UNITED STATES 1.458680e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.0-C.0-D.3` -----
/*
{
"id": "GQRY-A.0-B.0-C.0-D.3",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "receipt date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_receiptdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.371612e+09
1 ARGENTINA 1.477910e+09
2 BRAZIL 1.392735e+09
3 CANADA 1.473537e+09
4 EGYPT 1.430395e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.352876e+09
21 VIETNAM 1.388206e+09
22 RUSSIA 1.432095e+09
23 UNITED KINGDOM 1.377057e+09
24 UNITED STATES 1.459936e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.0-C.1-D.0` -----
/*
{
"id": "GQRY-A.0-B.0-C.1-D.0",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "order date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', o.o_orderdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.444741e+09
1 ARGENTINA 1.374122e+09
2 BRAZIL 1.394563e+09
3 CANADA 1.398804e+09
4 EGYPT 1.494428e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.170963e+09
21 VIETNAM 1.498923e+09
22 RUSSIA 1.430430e+09
23 UNITED KINGDOM 1.465177e+09
24 UNITED STATES 1.341487e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.0-C.1-D.1` -----
/*
{
"id": "GQRY-A.0-B.0-C.1-D.1",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "commitment date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_commitdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.445284e+09
1 ARGENTINA 1.377589e+09
2 BRAZIL 1.392838e+09
3 CANADA 1.410597e+09
4 EGYPT 1.495862e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.176301e+09
21 VIETNAM 1.502246e+09
22 RUSSIA 1.431899e+09
23 UNITED KINGDOM 1.467564e+09
24 UNITED STATES 1.342888e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.0-C.1-D.2` -----
/*
{
"id": "GQRY-A.0-B.0-C.1-D.2",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "shipment date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_shipdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.448186e+09
1 ARGENTINA 1.375787e+09
2 BRAZIL 1.393560e+09
3 CANADA 1.406102e+09
4 EGYPT 1.496119e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.181834e+09
21 VIETNAM 1.494862e+09
22 RUSSIA 1.439685e+09
23 UNITED KINGDOM 1.469671e+09
24 UNITED STATES 1.345821e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.0-C.1-D.3` -----
/*
{
"id": "GQRY-A.0-B.0-C.1-D.3",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "receipt date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_receiptdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.451888e+09
1 ARGENTINA 1.380059e+09
2 BRAZIL 1.393107e+09
3 CANADA 1.404266e+09
4 EGYPT 1.495924e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.186342e+09
21 VIETNAM 1.499671e+09
22 RUSSIA 1.434064e+09
23 UNITED KINGDOM 1.467076e+09
24 UNITED STATES 1.343885e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.1-C.0-D.0` -----
/*
{
"id": "GQRY-A.0-B.1-C.0-D.0",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "order date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', o.o_orderdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.216803e+09
1 ARGENTINA 1.268908e+09
2 BRAZIL 1.216649e+09
3 CANADA 1.286657e+09
4 EGYPT 1.268531e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.157969e+09
21 VIETNAM 1.198698e+09
22 RUSSIA 1.239588e+09
23 UNITED KINGDOM 1.192342e+09
24 UNITED STATES 1.278386e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.1-C.0-D.1` -----
/*
{
"id": "GQRY-A.0-B.1-C.0-D.1",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "commitment date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_commitdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.101136e+09
1 ARGENTINA 1.163497e+09
2 BRAZIL 1.110563e+09
3 CANADA 1.168849e+09
4 EGYPT 1.135858e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.065437e+09
21 VIETNAM 1.094700e+09
22 RUSSIA 1.134264e+09
23 UNITED KINGDOM 1.077683e+09
24 UNITED STATES 1.151289e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.1-C.0-D.2` -----
/*
{
"id": "GQRY-A.0-B.1-C.0-D.2",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "shipment date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_shipdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.093635e+09
1 ARGENTINA 1.168418e+09
2 BRAZIL 1.105024e+09
3 CANADA 1.167997e+09
4 EGYPT 1.135154e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.060590e+09
21 VIETNAM 1.097989e+09
22 RUSSIA 1.132029e+09
23 UNITED KINGDOM 1.083580e+09
24 UNITED STATES 1.150468e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.1-C.0-D.3` -----
/*
{
"id": "GQRY-A.0-B.1-C.0-D.3",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "receipt date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_receiptdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.061216e+09
1 ARGENTINA 1.140200e+09
2 BRAZIL 1.076624e+09
3 CANADA 1.136182e+09
4 EGYPT 1.102001e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.037847e+09
21 VIETNAM 1.068467e+09
22 RUSSIA 1.102167e+09
23 UNITED KINGDOM 1.058018e+09
24 UNITED STATES 1.121713e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.1-C.1-D.0` -----
/*
{
"id": "GQRY-A.0-B.1-C.1-D.0",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "order date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', o.o_orderdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.267838e+09
1 ARGENTINA 1.203253e+09
2 BRAZIL 1.216163e+09
3 CANADA 1.224317e+09
4 EGYPT 1.306827e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.029012e+09
21 VIETNAM 1.307602e+09
22 RUSSIA 1.253910e+09
23 UNITED KINGDOM 1.281547e+09
24 UNITED STATES 1.176022e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.1-C.1-D.1` -----
/*
{
"id": "GQRY-A.0-B.1-C.1-D.1",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "commitment date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_commitdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.149224e+09
1 ARGENTINA 1.091522e+09
2 BRAZIL 1.100428e+09
3 CANADA 1.111646e+09
4 EGYPT 1.184951e+09
... TRUNCATED ...
20 SAUDI ARABIA 9.335605e+08
21 VIETNAM 1.185007e+09
22 RUSSIA 1.137569e+09
23 UNITED KINGDOM 1.161422e+09
24 UNITED STATES 1.067787e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.1-C.1-D.2` -----
/*
{
"id": "GQRY-A.0-B.1-C.1-D.2",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "shipment date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_shipdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.147690e+09
1 ARGENTINA 1.090234e+09
2 BRAZIL 1.098946e+09
3 CANADA 1.108050e+09
4 EGYPT 1.183484e+09
... TRUNCATED ...
20 SAUDI ARABIA 9.369010e+08
21 VIETNAM 1.177723e+09
22 RUSSIA 1.139490e+09
23 UNITED KINGDOM 1.160627e+09
24 UNITED STATES 1.067053e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.0-B.1-C.1-D.3` -----
/*
{
"id": "GQRY-A.0-B.1-C.1-D.3",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "receipt date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "before discount (Gross revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_receiptdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.121381e+09
1 ARGENTINA 1.064187e+09
2 BRAZIL 1.072039e+09
3 CANADA 1.076277e+09
4 EGYPT 1.153133e+09
... TRUNCATED ...
20 SAUDI ARABIA 9.138240e+08
21 VIETNAM 1.150968e+09
22 RUSSIA 1.104405e+09
23 UNITED KINGDOM 1.126524e+09
24 UNITED STATES 1.037506e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.0-C.0-D.0` -----
/*
{
"id": "GQRY-A.1-B.0-C.0-D.0",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "order date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', o.o_orderdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.322656e+09
1 ARGENTINA 1.380994e+09
2 BRAZIL 1.312468e+09
3 CANADA 1.399526e+09
4 EGYPT 1.375549e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.260483e+09
21 VIETNAM 1.303431e+09
22 RUSSIA 1.343825e+09
23 UNITED KINGDOM 1.293430e+09
24 UNITED STATES 1.388316e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.0-C.0-D.1` -----
/*
{
"id": "GQRY-A.1-B.0-C.0-D.1",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "commitment date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_commitdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.313591e+09
1 ARGENTINA 1.393674e+09
2 BRAZIL 1.321117e+09
3 CANADA 1.400570e+09
4 EGYPT 1.361057e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.281946e+09
21 VIETNAM 1.308861e+09
22 RUSSIA 1.360609e+09
23 UNITED KINGDOM 1.296957e+09
24 UNITED STATES 1.386886e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.0-C.0-D.2` -----
/*
{
"id": "GQRY-A.1-B.0-C.0-D.2",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "shipment date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_shipdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.306616e+09
1 ARGENTINA 1.401871e+09
2 BRAZIL 1.320303e+09
3 CANADA 1.401921e+09
4 EGYPT 1.361305e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.280116e+09
21 VIETNAM 1.318167e+09
22 RUSSIA 1.359434e+09
23 UNITED KINGDOM 1.303841e+09
24 UNITED STATES 1.385345e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.0-C.0-D.3` -----
/*
{
"id": "GQRY-A.1-B.0-C.0-D.3",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "receipt date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_receiptdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.303468e+09
1 ARGENTINA 1.403933e+09
2 BRAZIL 1.323225e+09
3 CANADA 1.399833e+09
4 EGYPT 1.359065e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.285441e+09
21 VIETNAM 1.319037e+09
22 RUSSIA 1.361155e+09
23 UNITED KINGDOM 1.307979e+09
24 UNITED STATES 1.386675e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.0-C.1-D.0` -----
/*
{
"id": "GQRY-A.1-B.0-C.1-D.0",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "order date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', o.o_orderdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.372136e+09
1 ARGENTINA 1.305331e+09
2 BRAZIL 1.325274e+09
3 CANADA 1.329114e+09
4 EGYPT 1.419975e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.112572e+09
21 VIETNAM 1.424005e+09
22 RUSSIA 1.359067e+09
23 UNITED KINGDOM 1.391889e+09
24 UNITED STATES 1.274388e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.0-C.1-D.1` -----
/*
{
"id": "GQRY-A.1-B.0-C.1-D.1",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "commitment date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_commitdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.372741e+09
1 ARGENTINA 1.308413e+09
2 BRAZIL 1.323322e+09
3 CANADA 1.340381e+09
4 EGYPT 1.421444e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.117748e+09
21 VIETNAM 1.427302e+09
22 RUSSIA 1.360160e+09
23 UNITED KINGDOM 1.394291e+09
24 UNITED STATES 1.276003e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.0-C.1-D.2` -----
/*
{
"id": "GQRY-A.1-B.0-C.1-D.2",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "shipment date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_shipdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.375493e+09
1 ARGENTINA 1.306649e+09
2 BRAZIL 1.324206e+09
3 CANADA 1.336072e+09
4 EGYPT 1.421685e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.122922e+09
21 VIETNAM 1.420271e+09
22 RUSSIA 1.367748e+09
23 UNITED KINGDOM 1.396305e+09
24 UNITED STATES 1.278639e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.0-C.1-D.3` -----
/*
{
"id": "GQRY-A.1-B.0-C.1-D.3",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "receipt date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "include returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_receiptdate) = '1995'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.379075e+09
1 ARGENTINA 1.310707e+09
2 BRAZIL 1.323636e+09
3 CANADA 1.334341e+09
4 EGYPT 1.421487e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.127243e+09
21 VIETNAM 1.424742e+09
22 RUSSIA 1.362375e+09
23 UNITED KINGDOM 1.393908e+09
24 UNITED STATES 1.276787e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.1-C.0-D.0` -----
/*
{
"id": "GQRY-A.1-B.1-C.0-D.0",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "order date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', o.o_orderdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.156194e+09
1 ARGENTINA 1.205315e+09
2 BRAZIL 1.156222e+09
3 CANADA 1.222627e+09
4 EGYPT 1.204802e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.100023e+09
21 VIETNAM 1.138919e+09
22 RUSSIA 1.178057e+09
23 UNITED KINGDOM 1.132060e+09
24 UNITED STATES 1.214203e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.1-C.0-D.1` -----
/*
{
"id": "GQRY-A.1-B.1-C.0-D.1",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "commitment date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_commitdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.046445e+09
1 ARGENTINA 1.105303e+09
2 BRAZIL 1.055428e+09
3 CANADA 1.110574e+09
4 EGYPT 1.078878e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.012179e+09
21 VIETNAM 1.040148e+09
22 RUSSIA 1.078112e+09
23 UNITED KINGDOM 1.023241e+09
24 UNITED STATES 1.093509e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.1-C.0-D.2` -----
/*
{
"id": "GQRY-A.1-B.1-C.0-D.2",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "shipment date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_shipdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.039196e+09
1 ARGENTINA 1.109971e+09
2 BRAZIL 1.050142e+09
3 CANADA 1.109741e+09
4 EGYPT 1.078306e+09
... TRUNCATED ...
20 SAUDI ARABIA 1.007661e+09
21 VIETNAM 1.043226e+09
22 RUSSIA 1.076030e+09
23 UNITED KINGDOM 1.028654e+09
24 UNITED STATES 1.092705e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.1-C.0-D.3` -----
/*
{
"id": "GQRY-A.1-B.1-C.0-D.3",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "receipt date in 1995",
"[B] for each nation": "for each customer nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem l
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN customer c ON o.o_custkey = c.c_custkey
JOIN nation n ON c.c_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_receiptdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.008406e+09
1 ARGENTINA 1.083246e+09
2 BRAZIL 1.023142e+09
3 CANADA 1.079433e+09
4 EGYPT 1.046767e+09
... TRUNCATED ...
20 SAUDI ARABIA 9.860027e+08
21 VIETNAM 1.015163e+09
22 RUSSIA 1.047660e+09
23 UNITED KINGDOM 1.004586e+09
24 UNITED STATES 1.065502e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.1-C.1-D.0` -----
/*
{
"id": "GQRY-A.1-B.1-C.1-D.0",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "order date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN orders o ON o.o_orderkey = l.l_orderkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', o.o_orderdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.204142e+09
1 ARGENTINA 1.142928e+09
2 BRAZIL 1.155617e+09
3 CANADA 1.163298e+09
4 EGYPT 1.241591e+09
... TRUNCATED ...
20 SAUDI ARABIA 9.777254e+08
21 VIETNAM 1.242286e+09
22 RUSSIA 1.191288e+09
23 UNITED KINGDOM 1.217509e+09
24 UNITED STATES 1.117199e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.1-C.1-D.1` -----
/*
{
"id": "GQRY-A.1-B.1-C.1-D.1",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "commitment date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_commitdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.091553e+09
1 ARGENTINA 1.036746e+09
2 BRAZIL 1.045438e+09
3 CANADA 1.056443e+09
4 EGYPT 1.125809e+09
... TRUNCATED ...
20 SAUDI ARABIA 8.870358e+08
21 VIETNAM 1.125920e+09
22 RUSSIA 1.080588e+09
23 UNITED KINGDOM 1.103437e+09
24 UNITED STATES 1.014528e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.1-C.1-D.2` -----
/*
{
"id": "GQRY-A.1-B.1-C.1-D.2",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "shipment date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_shipdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.090171e+09
1 ARGENTINA 1.035419e+09
2 BRAZIL 1.044191e+09
3 CANADA 1.052946e+09
4 EGYPT 1.124439e+09
... TRUNCATED ...
20 SAUDI ARABIA 8.901037e+08
21 VIETNAM 1.118987e+09
22 RUSSIA 1.082594e+09
23 UNITED KINGDOM 1.102657e+09
24 UNITED STATES 1.013842e+09
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1-B.1-C.1-D.3` -----
/*
{
"id": "GQRY-A.1-B.1-C.1-D.3",
"parameter_names": [],
"parameter_values": {},
"other_exec_results": [],
"required_columns": [
1,
2
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] in 1995": "receipt date in 1995",
"[B] for each nation": "for each supplier nation",
"[C] total revenue": "after discount (Net revenue)",
"[D] total revenue": "exclude returned items"
}
}
}
*/
WITH revenue AS (
SELECT n.n_nationkey,
n.n_name,
COALESCE(SUM(l.l_extendedprice * (1 - l.l_discount)), 0) AS total_revenue
FROM lineitem AS l
JOIN supplier AS s ON s.s_suppkey = l.l_suppkey
JOIN nation AS n ON s.s_nationkey = n.n_nationkey
WHERE strftime('%Y', l.l_receiptdate) = '1995'
AND l.l_returnflag <> 'R'
GROUP BY n.n_nationkey, n.n_name
)
SELECT n.n_nationkey,
n.n_name,
COALESCE(r.total_revenue, 0) AS total_revenue
FROM nation n
LEFT JOIN revenue r ON r.n_nationkey = n.n_nationkey;
/* EXEC RESULT
n_nationkey n_name total_revenue
0 ALGERIA 1.065276e+09
1 ARGENTINA 1.010667e+09
2 BRAZIL 1.018542e+09
3 CANADA 1.022790e+09
4 EGYPT 1.095574e+09
... TRUNCATED ...
20 SAUDI ARABIA 8.681930e+08
21 VIETNAM 1.093447e+09
22 RUSSIA 1.049241e+09
23 UNITED KINGDOM 1.070262e+09
24 UNITED STATES 9.857484e+08
*/
----- END OF GOLD QUERY -----