请求 #1
SEQ 75{
"isolation_policy_hash": "fc37781752a4ab6f4ced846844f397a0bb6084032b5e0eb7059c83e9a9bf0e8f",
"status": "running"
}案例记录 case-run-00040
找出金额高于同客户分群已完成订单平均金额的已完成订单,输出 order_id、customer_id、segment、total_amount、segment_avg_amount,并按 total_amount 降序、order_id 升序;必须使用外层引用的相关子查询。
以下字段来自本次运行的冻结记录。
#12#401completed19,495不可估算未记录477mscodex_clitextgpt-5.6-solgpt-5.6-sol未提供2026年8月29日 16:382026年8月29日 16:390a4a18b4374f510f5eff18b06272c30c3375e1f082ae405adc8ead7dd9c81556显示本次实际保存的完整 Prompt。
你是 Text-to-SQL 生成器。只生成完成问题所需的 SQL 和简短可见摘要,不输出隐藏推理。
方言与安全规则:
Use DuckDB SQL. Return exactly one read-only query. Do not access files, URLs, extensions, or schemas outside the supplied tables.
数据库结构:
{"semantic_relationships":[{"cardinality":"many_to_one","from_entity":"order","sql_on":"fact_orders.customer_id = dim_customers.customer_id","to_entity":"customer"},{"cardinality":"many_to_one","from_entity":"order","sql_on":"fact_orders.channel_id = dim_channels.channel_id","to_entity":"channel"},{"cardinality":"many_to_one","from_entity":"order_item","sql_on":"fact_order_items.order_id = fact_orders.order_id","to_entity":"order"},{"cardinality":"many_to_one","from_entity":"order_item","sql_on":"fact_order_items.product_id = dim_products.product_id","to_entity":"product"},{"cardinality":"many_to_one","from_entity":"payment","sql_on":"fact_payments.order_id = fact_orders.order_id","to_entity":"order"},{"cardinality":"many_to_one","from_entity":"return","sql_on":"fact_returns.order_id = fact_order_items.order_id AND fact_returns.line_no = fact_order_items.line_no","to_entity":"order_item"}],"tables":[{"columns":[{"data_type":"BIGINT","name":"channel_id","nullable":false},{"data_type":"VARCHAR","name":"channel_name","nullable":false},{"data_type":"VARCHAR","name":"channel_type","nullable":false}],"foreign_keys":[],"name":"dim_channels","primary_key":["channel_id"]},{"columns":[{"data_type":"BIGINT","name":"customer_id","nullable":false},{"data_type":"VARCHAR","name":"customer_name","nullable":false},{"data_type":"VARCHAR","name":"city","nullable":true},{"data_type":"DATE","name":"signup_date","nullable":false},{"data_type":"VARCHAR","name":"segment","nullable":false}],"foreign_keys":[],"name":"dim_customers","primary_key":["customer_id"]},{"columns":[{"data_type":"BIGINT","name":"product_id","nullable":false},{"data_type":"VARCHAR","name":"product_name","nullable":false},{"data_type":"VARCHAR","name":"category","nullable":false},{"data_type":"VARCHAR","name":"brand","nullable":false},{"data_type":"DECIMAL(14,2)","name":"list_price","nullable":false}],"foreign_keys":[],"name":"dim_products","primary_key":["product_id"]},{"columns":[{"data_type":"BIGINT","name":"order_id","nullable":false},{"data_type":"BIGINT","name":"line_no","nullable":false},{"data_type":"BIGINT","name":"product_id","nullable":false},{"data_type":"BIGINT","name":"quantity","nullable":false},{"data_type":"DECIMAL(14,2)","name":"unit_price","nullable":false},{"data_type":"DECIMAL(14,2)","name":"discount_amount","nullable":false}],"foreign_keys":[{"columns":["order_id"],"referenced_columns":["order_id"],"referenced_table":"fact_orders"},{"columns":["product_id"],"referenced_columns":["product_id"],"referenced_table":"dim_products"}],"name":"fact_order_items","primary_key":["order_id","line_no"]},{"columns":[{"data_type":"BIGINT","name":"order_id","nullable":false},{"data_type":"BIGINT","name":"customer_id","nullable":false},{"data_type":"BIGINT","name":"channel_id","nullable":false},{"data_type":"DATE","name":"order_date","nullable":false},{"data_type":"VARCHAR","name":"status","nullable":false},{"data_type":"DECIMAL(14,2)","name":"total_amount","nullable":false}],"foreign_keys":[{"columns":["customer_id"],"referenced_columns":["customer_id"],"referenced_table":"dim_customers"},{"columns":["channel_id"],"referenced_columns":["channel_id"],"referenced_table":"dim_channels"}],"name":"fact_orders","primary_key":["order_id"]},{"columns":[{"data_type":"BIGINT","name":"payment_id","nullable":false},{"data_type":"BIGINT","name":"order_id","nullable":false},{"data_type":"TIMESTAMP","name":"paid_at","nullable":false},{"data_type":"VARCHAR","name":"payment_method","nullable":false},{"data_type":"DECIMAL(14,2)","name":"amount","nullable":false},{"data_type":"VARCHAR","name":"status","nullable":false}],"foreign_keys":[{"columns":["order_id"],"referenced_columns":["order_id"],"referenced_table":"fact_orders"}],"name":"fact_payments","primary_key":["payment_id"]},{"columns":[{"data_type":"BIGINT","name":"return_id","nullable":false},{"data_type":"BIGINT","name":"order_id","nullable":false},{"data_type":"BIGINT","name":"line_no","nullable":false},{"data_type":"TIMESTAMP","name":"returned_at","nullable":false},{"data_type":"BIGINT","name":"return_qty","nullable":false},{"data_type":"DECIMAL(14,2)","name":"refund_amount","nullable":false},{"data_type":"VARCHAR","name":"reason","nullable":true}],"foreign_keys":[{"columns":["order_id","line_no"],"referenced_columns":["order_id","line_no"],"referenced_table":"fact_order_items"}],"name":"fact_returns","primary_key":["return_id"]}]}
语义层与业务口径:
{"business_rules":["完成订单仅指 fact_orders.status = 'completed'。","净销售额为 quantity * unit_price - discount_amount。","paid、refunded、failed 金额只按 fact_payments.status 分类。","退货率为完成订单的 returned_qty / sold_qty,售出数量仅含完成订单。","月份按 UTC Gregorian calendar 计算。"],"dimensions":[{"data_type":"VARCHAR","description":"客户分群","expression":"dim_customers.segment","name":"customer_segment"},{"data_type":"VARCHAR","description":"商品品类","expression":"dim_products.category","name":"product_category"},{"data_type":"VARCHAR","description":"渠道类型","expression":"dim_channels.channel_type","name":"channel_type"},{"data_type":"VARCHAR","description":"UTC Gregorian 月份","expression":"strftime(fact_orders.order_date, '%Y-%m')","name":"order_month"}],"entities":[{"description":"客户主数据","grain":"每行一个客户","name":"customer","primary_key":["customer_id"],"table":"dim_customers"},{"description":"商品主数据","grain":"每行一个商品","name":"product","primary_key":["product_id"],"table":"dim_products"},{"description":"渠道主数据","grain":"每行一个渠道","name":"channel","primary_key":["channel_id"],"table":"dim_channels"},{"description":"订单头","grain":"每行一个订单","name":"order","primary_key":["order_id"],"table":"fact_orders"},{"description":"订单行","grain":"每行一个订单商品行","name":"order_item","primary_key":["order_id","line_no"],"table":"fact_order_items"},{"description":"支付尝试","grain":"每行一笔支付","name":"payment","primary_key":["payment_id"],"table":"fact_payments"},{"description":"退货记录","grain":"每行一条订单行退货","name":"return","primary_key":["return_id"],"table":"fact_returns"}],"metrics":[{"description":"已完成订单数","expression":"COUNT(DISTINCT CASE WHEN fact_orders.status = 'completed' THEN fact_orders.order_id END)","filters":["fact_orders.status = 'completed'"],"grain":"聚合","name":"completed_order_count"},{"description":"完成订单商品行净销售额","expression":"SUM(fact_order_items.quantity * fact_order_items.unit_price - fact_order_items.discount_amount)","filters":["fact_orders.status = 'completed'"],"grain":"聚合","name":"net_revenue"},{"description":"成功支付金额","expression":"SUM(CASE WHEN fact_payments.status = 'paid' THEN fact_payments.amount ELSE 0 END)","filters":[],"grain":"聚合","name":"paid_amount"},{"description":"退款状态支付金额","expression":"SUM(CASE WHEN fact_payments.status = 'refunded' THEN fact_payments.amount ELSE 0 END)","filters":[],"grain":"聚合","name":"refunded_amount"},{"description":"失败支付金额","expression":"SUM(CASE WHEN fact_payments.status = 'failed' THEN fact_payments.amount ELSE 0 END)","filters":[],"grain":"聚合","name":"failed_amount"},{"description":"完成订单退货数量除以售出数量","expression":"SUM(fact_returns.return_qty) / SUM(fact_order_items.quantity)","filters":["fact_orders.status = 'completed'"],"grain":"聚合","name":"return_rate"}],"relationships":[{"cardinality":"many_to_one","from_entity":"order","sql_on":"fact_orders.customer_id = dim_customers.customer_id","to_entity":"customer"},{"cardinality":"many_to_one","from_entity":"order","sql_on":"fact_orders.channel_id = dim_channels.channel_id","to_entity":"channel"},{"cardinality":"many_to_one","from_entity":"order_item","sql_on":"fact_order_items.order_id = fact_orders.order_id","to_entity":"order"},{"cardinality":"many_to_one","from_entity":"order_item","sql_on":"fact_order_items.product_id = dim_products.product_id","to_entity":"product"},{"cardinality":"many_to_one","from_entity":"payment","sql_on":"fact_payments.order_id = fact_orders.order_id","to_entity":"order"},{"cardinality":"many_to_one","from_entity":"return","sql_on":"fact_returns.order_id = fact_order_items.order_id AND fact_returns.line_no = fact_order_items.line_no","to_entity":"order_item"}]}
问题:
找出金额高于同客户分群已完成订单平均金额的已完成订单,输出 order_id、customer_id、segment、total_amount、segment_avg_amount,并按 total_amount 降序、order_id 升序;必须使用外层引用的相关子查询。
输出必须严格匹配此 JSON Schema:
{"additionalProperties":false,"properties":{"assumptions":{"items":{"type":"string"},"title":"Assumptions","type":"array"},"sql":{"title":"Sql","type":"string"},"summary":{"title":"Summary","type":"string"}},"required":["sql","summary","assumptions"],"title":"GenerationOutput","type":"object"}按事件序号排列;密钥和 Authorization 已移除。
历史证据边界:完整 Prompt 已保存,但这次 codex_cli 记录没有保存底层 HTTP 报文或 CLI 参数。本站不会把推测内容伪装成原始请求;未来运行会在 provider.requested 中记录脱敏后的完整调用信封。
SEQ 75{
"isolation_policy_hash": "fc37781752a4ab6f4ced846844f397a0bb6084032b5e0eb7059c83e9a9bf0e8f",
"status": "running"
}分别显示原始响应、解析结果和 SQL。
{"sql":"SELECT\n o.order_id,\n o.customer_id,\n c.segment,\n o.total_amount,\n (\n SELECT AVG(o2.total_amount)\n FROM fact_orders AS o2\n JOIN dim_customers AS c2\n ON o2.customer_id = c2.customer_id\n WHERE o2.status = 'completed'\n AND c2.segment = c.segment\n ) AS segment_avg_amount\nFROM fact_orders AS o\nJOIN dim_customers AS c\n ON o.customer_id = c.customer_id\nWHERE o.status = 'completed'\n AND o.total_amount > (\n SELECT AVG(o3.total_amount)\n FROM fact_orders AS o3\n JOIN dim_customers AS c3\n ON o3.customer_id = c3.customer_id\n WHERE o3.status = 'completed'\n AND c3.segment = c.segment\n )\nORDER BY o.total_amount DESC, o.order_id ASC;","summary":"返回金额高于其客户分群已完成订单平均金额的已完成订单,并按订单金额降序、订单 ID 升序排列。","assumptions":["订单金额使用 fact_orders.total_amount。","分群平均金额按该分群全部已完成订单计算,每个订单计入一次。"]}没有可解析方案。
SELECT
o.order_id,
o.customer_id,
c.segment,
o.total_amount,
(
SELECT AVG(o2.total_amount)
FROM fact_orders AS o2
JOIN dim_customers AS c2
ON o2.customer_id = c2.customer_id
WHERE o2.status = 'completed'
AND c2.segment = c.segment
) AS segment_avg_amount
FROM fact_orders AS o
JOIN dim_customers AS c
ON o.customer_id = c.customer_id
WHERE o.status = 'completed'
AND o.total_amount > (
SELECT AVG(o3.total_amount)
FROM fact_orders AS o3
JOIN dim_customers AS c3
ON o3.customer_id = c3.customer_id
WHERE o3.status = 'completed'
AND c3.segment = c.segment
)
ORDER BY o.total_amount DESC, o.order_id ASC;SELECT
o.order_id,
o.customer_id,
c.segment,
o.total_amount,
(
SELECT
AVG(o2.total_amount)
FROM fact_orders AS o2
JOIN dim_customers AS c2
ON o2.customer_id = c2.customer_id
WHERE
o2.status = 'completed' AND c2.segment = c.segment
) AS segment_avg_amount
FROM fact_orders AS o
JOIN dim_customers AS c
ON o.customer_id = c.customer_id
WHERE
o.status = 'completed'
AND o.total_amount > (
SELECT
AVG(o3.total_amount)
FROM fact_orders AS o3
JOIN dim_customers AS c3
ON o3.customer_id = c3.customer_id
WHERE
o3.status = 'completed' AND c3.segment = c.segment
)
ORDER BY
o.total_amount DESC,
o.order_id ASC{
"token_usage": {
"cache_write_input_tokens": 0,
"cached_input_tokens": 9984,
"input_tokens": 19142,
"output_tokens": 353,
"reasoning_output_tokens": 64
},
"generation_ms": null,
"execution_ms": 476.7052919996786
}包含评分明细、参考 SQL、结构要求、比较规则和结果差异。
{
"ast_rules": [
{
"details": {
"actual": 2,
"required": 1
},
"id": "correlated",
"kind": "correlated_subquery",
"passed": true
}
],
"column_count": 5,
"column_names": 5,
"execution": 10,
"ordering": 10,
"protocol": 5,
"read_only_ast": 5,
"row_f1": 45,
"sql_capability": 15,
"total": 100
}SELECT o.order_id, o.customer_id, c.segment, o.total_amount, a.segment_avg_amount FROM fact_orders o JOIN dim_customers c ON c.customer_id = o.customer_id JOIN LATERAL (SELECT ROUND(AVG(o2.total_amount), 2) AS segment_avg_amount FROM fact_orders o2 JOIN dim_customers c2 ON c2.customer_id = o2.customer_id WHERE o2.status = 'completed' AND c2.segment = c.segment) a ON TRUE WHERE o.status = 'completed' AND o.total_amount > a.segment_avg_amount ORDER BY o.total_amount DESC, o.order_id ASC[
{
"id": "correlated",
"kind": "correlated_subquery",
"min": 1
}
]{
"abs_tolerance": "0.005",
"decimal_scale": 2,
"duplicate_policy": "multiset",
"max_rows": 10000,
"rel_tolerance": "0",
"row_order_significant": true
}{
"columns": [
{
"name": "order_id",
"type": "BIGINT"
},
{
"name": "customer_id",
"type": "BIGINT"
},
{
"name": "segment",
"type": "VARCHAR"
},
{
"name": "total_amount",
"type": "DECIMAL(14,2)"
},
{
"name": "segment_avg_amount",
"type": "DOUBLE"
}
],
"digest": "9ff6d9203b1fe6cbdc9b4682f3a261e1ec9b367d85dd1e6c1256fc6d56144ed0",
"row_count": 232,
"rows": [
[
162,
70,
"core",
"3834.75",
"1213.07"
],
[
413,
46,
"core",
"3468.75",
"1213.07"
],
[
598,
39,
"vip",
"3425.75",
"1254.16"
],
[
234,
109,
"growth",
"3290.25",
"1117.24"
],
[
599,
107,
"vip",
"3282.50",
"1254.16"
],
[
562,
59,
"vip",
"3278.25",
"1254.16"
],
[
157,
2,
"core",
"3065.50",
"1213.07"
],
[
497,
78,
"core",
"3039.75",
"1213.07"
],
[
529,
95,
"vip",
"3037.25",
"1254.16"
],
[
94,
80,
"new",
"3035.50",
"1078.87"
],
[
315,
65,
"growth",
"3006.75",
"1117.24"
],
[
423,
20,
"new",
"2991.50",
"1078.87"
],
[
135,
29,
"growth",
"2926.25",
"1117.24"
],
[
532,
85,
"growth",
"2868.25",
"1117.24"
],
[
287,
80,
"new",
"2831.00",
"1078.87"
],
[
133,
89,
"growth",
"2799.00",
"1117.24"
],
[
93,
44,
"new",
"2775.50",
"1078.87"
],
[
36,
65,
"growth",
"2756.25",
"1117.24"
],
[
242,
5,
"growth",
"2751.75",
"1117.24"
],
[
44,
59,
"vip",
"2743.00",
"1254.16"
],
[
396,
74,
"core",
"2737.25",
"1213.07"
],
[
365,
107,
"vip",
"2710.00",
"1254.16"
],
[
238,
14,
"core",
"2697.00",
"1213.07"
],
[
198,
10,
"core",
"2665.75",
"1213.07"
],
[
117,
92,
"new",
"2587.75",
"1078.87"
],
[
403,
43,
"vip",
"2573.00",
"1254.16"
],
[
468,
34,
"core",
"2459.50",
"1213.07"
],
[
194,
104,
"new",
"2419.00",
"1078.87"
],
[
255,
17,
"growth",
"2417.25",
"1117.24"
],
[
327,
43,
"vip",
"2405.75",
"1254.16"
],
[
206,
63,
"vip",
"2372.00",
"1254.16"
],
[
228,
56,
"new",
"2371.75",
"1078.87"
],
[
503,
44,
"new",
"2363.25",
"1078.87"
],
[
587,
85,
"growth",
"2334.50",
"1117.24"
],
[
556,
98,
"core",
"2318.00",
"1213.07"
],
[
38,
95,
"vip",
"2307.75",
"1254.16"
],
[
545,
2,
"core",
"2307.25",
"1213.07"
],
[
144,
38,
"core",
"2272.25",
"1213.07"
],
[
526,
27,
"vip",
"2269.75",
"1254.16"
],
[
368,
45,
"growth",
"2257.25",
"1117.24"
],
[
105,
19,
"vip",
"2244.75",
"1254.16"
],
[
356,
44,
"new",
"2234.00",
"1078.87"
],
[
395,
1,
"growth",
"2230.25",
"1117.24"
],
[
374,
61,
"growth",
"2220.75",
"1117.24"
],
[
183,
82,
"core",
"2219.25",
"1213.07"
],
[
512,
72,
"new",
"2211.75",
"1078.87"
],
[
65,
61,
"growth",
"2208.75",
"1117.24"
],
[
444,
69,
"growth",
"2185.50",
"1117.24"
],
[
202,
109,
"growth",
"2177.25",
"1117.24"
],
[
27,
85,
"growth",
"2174.50",
"1117.24"
],
[
597,
94,
"core",
"2167.75",
"1213.07"
],
[
434,
91,
"vip",
"2164.50",
"1254.16"
],
[
145,
31,
"vip",
"2161.50",
"1254.16"
],
[
134,
52,
"new",
"2158.25",
"1078.87"
],
[
506,
21,
"growth",
"2151.50",
"1117.24"
],
[
386,
39,
"vip",
"2137.25",
"1254.16"
],
[
272,
32,
"new",
"2114.75",
"1078.87"
],
[
258,
82,
"core",
"2108.00",
"1213.07"
],
[
62,
50,
"core",
"2106.25",
"1213.07"
],
[
227,
50,
"core",
"2095.50",
"1213.07"
],
[
324,
21,
"growth",
"2077.75",
"1117.24"
],
[
159,
34,
"core",
"2060.50",
"1213.07"
],
[
447,
38,
"core",
"2050.25",
"1213.07"
],
[
377,
106,
"core",
"2049.75",
"1213.07"
],
[
279,
40,
"new",
"2018.50",
"1078.87"
],
[
132,
17,
"growth",
"2007.50",
"1117.24"
],
[
98,
21,
"growth",
"1982.25",
"1117.24"
],
[
68,
13,
"growth",
"1975.75",
"1117.24"
],
[
266,
58,
"core",
"1969.00",
"1213.07"
],
[
452,
42,
"core",
"1968.75",
"1213.07"
],
[
172,
62,
"core",
"1968.00",
"1213.07"
],
[
298,
94,
"core",
"1951.25",
"1213.07"
],
[
469,
97,
"growth",
"1936.50",
"1117.24"
],
[
406,
51,
"vip",
"1933.50",
"1254.16"
],
[
257,
31,
"vip",
"1930.25",
"1254.16"
],
[
107,
66,
"core",
"1924.50",
"1213.07"
],
[
392,
96,
"new",
"1922.25",
"1078.87"
],
[
143,
60,
"new",
"1922.00",
"1078.87"
],
[
63,
94,
"core",
"1911.25",
"1213.07"
],
[
47,
24,
"new",
"1908.50",
"1078.87"
],
[
274,
89,
"growth",
"1891.50",
"1117.24"
],
[
523,
60,
"new",
"1890.50",
"1078.87"
],
[
504,
107,
"vip",
"1890.00",
"1254.16"
],
[
57,
105,
"growth",
"1888.25",
"1117.24"
],
[
252,
13,
"growth",
"1875.75",
"1117.24"
],
[
73,
46,
"core",
"1856.50",
"1213.07"
],
[
375,
49,
"growth",
"1846.75",
"1117.24"
],
[
472,
71,
"vip",
"1846.25",
"1254.16"
],
[
127,
51,
"vip",
"1817.50",
"1254.16"
],
[
383,
32,
"new",
"1816.75",
"1078.87"
],
[
393,
6,
"core",
"1809.25",
"1213.07"
],
[
566,
104,
"new",
"1799.25",
"1078.87"
],
[
334,
14,
"core",
"1798.50",
"1213.07"
],
[
129,
93,
"growth",
"1798.00",
"1117.24"
],
[
192,
76,
"new",
"1793.75",
"1078.87"
],
[
578,
104,
"new",
"1791.00",
"1078.87"
],
[
388,
15,
"vip",
"1789.75",
"1254.16"
],
[
549,
10,
"core",
"1789.75",
"1213.07"
],
[
49,
14,
"core",
"1789.00",
"1213.07"
],
[
397,
67,
"vip",
"1785.00",
"1254.16"
],
[
213,
28,
"new",
"1780.75",
"1078.87"
],
[
323,
85,
"growth",
"1780.50",
"1117.24"
],
[
405,
79,
"vip",
"1774.50",
"1254.16"
],
[
95,
15,
"vip",
"1770.50",
"1254.16"
],
[
338,
35,
"vip",
"1760.75",
"1254.16"
],
[
422,
79,
"vip",
"1758.00",
"1254.16"
],
[
459,
106,
"core",
"1756.75",
"1213.07"
],
[
112,
17,
"growth",
"1742.50",
"1117.24"
],
[
3,
48,
"new",
"1735.00",
"1078.87"
],
[
177,
93,
"growth",
"1732.50",
"1117.24"
],
[
335,
22,
"core",
"1727.00",
"1213.07"
],
[
55,
69,
"growth",
"1714.25",
"1117.24"
],
[
6,
31,
"vip",
"1713.50",
"1254.16"
],
[
229,
12,
"new",
"1696.75",
"1078.87"
],
[
138,
64,
"new",
"1695.25",
"1078.87"
],
[
296,
48,
"new",
"1692.00",
"1078.87"
],
[
336,
61,
"growth",
"1691.75",
"1117.24"
],
[
179,
110,
"core",
"1690.25",
"1213.07"
],
[
193,
67,
"vip",
"1683.75",
"1254.16"
],
[
89,
108,
"new",
"1676.75",
"1078.87"
],
[
4,
32,
"new",
"1676.25",
"1078.87"
],
[
424,
56,
"new",
"1670.75",
"1078.87"
],
[
369,
35,
"vip",
"1667.50",
"1254.16"
],
[
248,
26,
"core",
"1663.75",
"1213.07"
],
[
22,
88,
"new",
"1656.25",
"1078.87"
],
[
486,
20,
"new",
"1655.50",
"1078.87"
],
[
54,
38,
"core",
"1655.25",
"1213.07"
],
[
427,
2,
"core",
"1655.00",
"1213.07"
],
[
147,
29,
"growth",
"1648.00",
"1117.24"
],
[
349,
13,
"growth",
"1646.50",
"1117.24"
],
[
223,
67,
"vip",
"1640.00",
"1254.16"
],
[
419,
21,
"growth",
"1638.50",
"1117.24"
],
[
216,
57,
"growth",
"1628.00",
"1117.24"
],
[
42,
12,
"new",
"1624.25",
"1078.87"
],
[
305,
53,
"growth",
"1621.75",
"1117.24"
],
[
586,
33,
"growth",
"1616.00",
"1117.24"
],
[
292,
65,
"growth",
"1609.75",
"1117.24"
],
[
328,
83,
"vip",
"1607.00",
"1254.16"
],
[
5,
55,
"vip",
"1589.50",
"1254.16"
],
[
495,
74,
"core",
"1587.00",
"1213.07"
],
[
589,
24,
"new",
"1584.50",
"1078.87"
],
[
508,
12,
"new",
"1584.25",
"1078.87"
],
[
154,
80,
"new",
"1581.00",
"1078.87"
],
[
39,
44,
"new",
"1565.00",
"1078.87"
],
[
123,
56,
"new",
"1561.75",
"1078.87"
],
[
146,
50,
"core",
"1535.75",
"1213.07"
],
[
246,
82,
"core",
"1522.00",
"1213.07"
],
[
254,
17,
"growth",
"1520.25",
"1117.24"
],
[
9,
104,
"new",
"1516.00",
"1078.87"
],
[
554,
86,
"core",
"1515.25",
"1213.07"
],
[
404,
58,
"core",
"1512.25",
"1213.07"
],
[
502,
66,
"core",
"1511.00",
"1213.07"
],
[
372,
67,
"vip",
"1507.50",
"1254.16"
],
[
409,
47,
"vip",
"1506.25",
"1254.16"
],
[
167,
1,
"growth",
"1501.50",
"1117.24"
],
[
346,
71,
"vip",
"1498.50",
"1254.16"
],
[
148,
95,
"vip",
"1496.75",
"1254.16"
],
[
399,
109,
"growth",
"1493.00",
"1117.24"
],
[
509,
21,
"growth",
"1492.75",
"1117.24"
],
[
564,
46,
"core",
"1491.25",
"1213.07"
],
[
267,
17,
"growth",
"1489.00",
"1117.24"
],
[
283,
53,
"growth",
"1487.50",
"1117.24"
],
[
276,
13,
"growth",
"1485.00",
"1117.24"
],
[
585,
100,
"new",
"1484.00",
"1078.87"
],
[
82,
80,
"new",
"1471.50",
"1078.87"
],
[
414,
13,
"growth",
"1471.00",
"1117.24"
],
[
387,
12,
"new",
"1468.75",
"1078.87"
],
[
103,
95,
"vip",
"1464.25",
"1254.16"
],
[
343,
84,
"new",
"1462.50",
"1078.87"
],
[
77,
41,
"growth",
"1458.25",
"1117.24"
],
[
174,
35,
"vip",
"1458.00",
"1254.16"
],
[
518,
43,
"vip",
"1450.50",
"1254.16"
],
[
199,
92,
"new",
"1449.50",
"1078.87"
],
[
106,
78,
"core",
"1442.25",
"1213.07"
],
[
306,
104,
"new",
"1438.25",
"1078.87"
],
[
402,
110,
"core",
"1421.25",
"1213.07"
],
[
546,
83,
"vip",
"1419.50",
"1254.16"
],
[
478,
96,
"new",
"1415.00",
"1078.87"
],
[
215,
71,
"vip",
"1411.50",
"1254.16"
],
[
567,
48,
"new",
"1409.50",
"1078.87"
],
[
514,
9,
"growth",
"1397.00",
"1117.24"
],
[
575,
55,
"vip",
"1392.50",
"1254.16"
],
[
52,
90,
"core",
"1376.75",
"1213.07"
],
[
438,
34,
"core",
"1373.00",
"1213.07"
],
[
542,
31,
"vip",
"1372.50",
"1254.16"
],
[
243,
92,
"new",
"1371.50",
"1078.87"
],
[
294,
10,
"core",
"1370.00",
"1213.07"
],
[
339,
81,
"growth",
"1368.75",
"1117.24"
],
[
537,
93,
"growth",
"1363.25",
"1117.24"
],
[
293,
59,
"vip",
"1361.25",
"1254.16"
],
[
453,
108,
"new",
"1359.50",
"1078.87"
],
[
449,
97,
"growth",
"1357.00",
"1117.24"
],
[
477,
24,
"new",
"1355.25",
"1078.87"
],
[
573,
67,
"vip",
"1351.00",
"1254.16"
],
[
14,
69,
"growth",
"1350.00",
"1117.24"
],
[
364,
53,
"growth",
"1349.25",
"1117.24"
],
[
594,
41,
"growth",
"1345.50",
"1117.24"
],
[
568,
84,
"new",
"1343.00",
"1078.87"
],
[
463,
107,
"vip",
"1342.25",
"1254.16"
],
[
299,
29,
"growth",
"1341.50",
"1117.24"
]
]
}{
"columns": [
{
"name": "order_id",
"type": "BIGINT"
},
{
"name": "customer_id",
"type": "BIGINT"
},
{
"name": "segment",
"type": "VARCHAR"
},
{
"name": "total_amount",
"type": "DECIMAL(14,2)"
},
{
"name": "segment_avg_amount",
"type": "DOUBLE"
}
],
"extra": [],
"missing": [],
"row_count": 232,
"rows": [
[
162,
70,
"core",
"3834.75",
1213.0695652173913
],
[
413,
46,
"core",
"3468.75",
1213.0695652173913
],
[
598,
39,
"vip",
"3425.75",
1254.1552631578948
],
[
234,
109,
"growth",
"3290.25",
1117.2432432432433
],
[
599,
107,
"vip",
"3282.50",
1254.1552631578948
],
[
562,
59,
"vip",
"3278.25",
1254.1552631578948
],
[
157,
2,
"core",
"3065.50",
1213.0695652173913
],
[
497,
78,
"core",
"3039.75",
1213.0695652173913
],
[
529,
95,
"vip",
"3037.25",
1254.1552631578948
],
[
94,
80,
"new",
"3035.50",
1078.868
],
[
315,
65,
"growth",
"3006.75",
1117.2432432432433
],
[
423,
20,
"new",
"2991.50",
1078.868
],
[
135,
29,
"growth",
"2926.25",
1117.2432432432433
],
[
532,
85,
"growth",
"2868.25",
1117.2432432432433
],
[
287,
80,
"new",
"2831.00",
1078.868
],
[
133,
89,
"growth",
"2799.00",
1117.2432432432433
],
[
93,
44,
"new",
"2775.50",
1078.868
],
[
36,
65,
"growth",
"2756.25",
1117.2432432432433
],
[
242,
5,
"growth",
"2751.75",
1117.2432432432433
],
[
44,
59,
"vip",
"2743.00",
1254.1552631578948
],
[
396,
74,
"core",
"2737.25",
1213.0695652173913
],
[
365,
107,
"vip",
"2710.00",
1254.1552631578948
],
[
238,
14,
"core",
"2697.00",
1213.0695652173913
],
[
198,
10,
"core",
"2665.75",
1213.0695652173913
],
[
117,
92,
"new",
"2587.75",
1078.868
],
[
403,
43,
"vip",
"2573.00",
1254.1552631578948
],
[
468,
34,
"core",
"2459.50",
1213.0695652173913
],
[
194,
104,
"new",
"2419.00",
1078.868
],
[
255,
17,
"growth",
"2417.25",
1117.2432432432433
],
[
327,
43,
"vip",
"2405.75",
1254.1552631578948
],
[
206,
63,
"vip",
"2372.00",
1254.1552631578948
],
[
228,
56,
"new",
"2371.75",
1078.868
],
[
503,
44,
"new",
"2363.25",
1078.868
],
[
587,
85,
"growth",
"2334.50",
1117.2432432432433
],
[
556,
98,
"core",
"2318.00",
1213.0695652173913
],
[
38,
95,
"vip",
"2307.75",
1254.1552631578948
],
[
545,
2,
"core",
"2307.25",
1213.0695652173913
],
[
144,
38,
"core",
"2272.25",
1213.0695652173913
],
[
526,
27,
"vip",
"2269.75",
1254.1552631578948
],
[
368,
45,
"growth",
"2257.25",
1117.2432432432433
],
[
105,
19,
"vip",
"2244.75",
1254.1552631578948
],
[
356,
44,
"new",
"2234.00",
1078.868
],
[
395,
1,
"growth",
"2230.25",
1117.2432432432433
],
[
374,
61,
"growth",
"2220.75",
1117.2432432432433
],
[
183,
82,
"core",
"2219.25",
1213.0695652173913
],
[
512,
72,
"new",
"2211.75",
1078.868
],
[
65,
61,
"growth",
"2208.75",
1117.2432432432433
],
[
444,
69,
"growth",
"2185.50",
1117.2432432432433
],
[
202,
109,
"growth",
"2177.25",
1117.2432432432433
],
[
27,
85,
"growth",
"2174.50",
1117.2432432432433
],
[
597,
94,
"core",
"2167.75",
1213.0695652173913
],
[
434,
91,
"vip",
"2164.50",
1254.1552631578948
],
[
145,
31,
"vip",
"2161.50",
1254.1552631578948
],
[
134,
52,
"new",
"2158.25",
1078.868
],
[
506,
21,
"growth",
"2151.50",
1117.2432432432433
],
[
386,
39,
"vip",
"2137.25",
1254.1552631578948
],
[
272,
32,
"new",
"2114.75",
1078.868
],
[
258,
82,
"core",
"2108.00",
1213.0695652173913
],
[
62,
50,
"core",
"2106.25",
1213.0695652173913
],
[
227,
50,
"core",
"2095.50",
1213.0695652173913
],
[
324,
21,
"growth",
"2077.75",
1117.2432432432433
],
[
159,
34,
"core",
"2060.50",
1213.0695652173913
],
[
447,
38,
"core",
"2050.25",
1213.0695652173913
],
[
377,
106,
"core",
"2049.75",
1213.0695652173913
],
[
279,
40,
"new",
"2018.50",
1078.868
],
[
132,
17,
"growth",
"2007.50",
1117.2432432432433
],
[
98,
21,
"growth",
"1982.25",
1117.2432432432433
],
[
68,
13,
"growth",
"1975.75",
1117.2432432432433
],
[
266,
58,
"core",
"1969.00",
1213.0695652173913
],
[
452,
42,
"core",
"1968.75",
1213.0695652173913
],
[
172,
62,
"core",
"1968.00",
1213.0695652173913
],
[
298,
94,
"core",
"1951.25",
1213.0695652173913
],
[
469,
97,
"growth",
"1936.50",
1117.2432432432433
],
[
406,
51,
"vip",
"1933.50",
1254.1552631578948
],
[
257,
31,
"vip",
"1930.25",
1254.1552631578948
],
[
107,
66,
"core",
"1924.50",
1213.0695652173913
],
[
392,
96,
"new",
"1922.25",
1078.868
],
[
143,
60,
"new",
"1922.00",
1078.868
],
[
63,
94,
"core",
"1911.25",
1213.0695652173913
],
[
47,
24,
"new",
"1908.50",
1078.868
],
[
274,
89,
"growth",
"1891.50",
1117.2432432432433
],
[
523,
60,
"new",
"1890.50",
1078.868
],
[
504,
107,
"vip",
"1890.00",
1254.1552631578948
],
[
57,
105,
"growth",
"1888.25",
1117.2432432432433
],
[
252,
13,
"growth",
"1875.75",
1117.2432432432433
],
[
73,
46,
"core",
"1856.50",
1213.0695652173913
],
[
375,
49,
"growth",
"1846.75",
1117.2432432432433
],
[
472,
71,
"vip",
"1846.25",
1254.1552631578948
],
[
127,
51,
"vip",
"1817.50",
1254.1552631578948
],
[
383,
32,
"new",
"1816.75",
1078.868
],
[
393,
6,
"core",
"1809.25",
1213.0695652173913
],
[
566,
104,
"new",
"1799.25",
1078.868
],
[
334,
14,
"core",
"1798.50",
1213.0695652173913
],
[
129,
93,
"growth",
"1798.00",
1117.2432432432433
],
[
192,
76,
"new",
"1793.75",
1078.868
],
[
578,
104,
"new",
"1791.00",
1078.868
],
[
388,
15,
"vip",
"1789.75",
1254.1552631578948
],
[
549,
10,
"core",
"1789.75",
1213.0695652173913
],
[
49,
14,
"core",
"1789.00",
1213.0695652173913
],
[
397,
67,
"vip",
"1785.00",
1254.1552631578948
],
[
213,
28,
"new",
"1780.75",
1078.868
],
[
323,
85,
"growth",
"1780.50",
1117.2432432432433
],
[
405,
79,
"vip",
"1774.50",
1254.1552631578948
],
[
95,
15,
"vip",
"1770.50",
1254.1552631578948
],
[
338,
35,
"vip",
"1760.75",
1254.1552631578948
],
[
422,
79,
"vip",
"1758.00",
1254.1552631578948
],
[
459,
106,
"core",
"1756.75",
1213.0695652173913
],
[
112,
17,
"growth",
"1742.50",
1117.2432432432433
],
[
3,
48,
"new",
"1735.00",
1078.868
],
[
177,
93,
"growth",
"1732.50",
1117.2432432432433
],
[
335,
22,
"core",
"1727.00",
1213.0695652173913
],
[
55,
69,
"growth",
"1714.25",
1117.2432432432433
],
[
6,
31,
"vip",
"1713.50",
1254.1552631578948
],
[
229,
12,
"new",
"1696.75",
1078.868
],
[
138,
64,
"new",
"1695.25",
1078.868
],
[
296,
48,
"new",
"1692.00",
1078.868
],
[
336,
61,
"growth",
"1691.75",
1117.2432432432433
],
[
179,
110,
"core",
"1690.25",
1213.0695652173913
],
[
193,
67,
"vip",
"1683.75",
1254.1552631578948
],
[
89,
108,
"new",
"1676.75",
1078.868
],
[
4,
32,
"new",
"1676.25",
1078.868
],
[
424,
56,
"new",
"1670.75",
1078.868
],
[
369,
35,
"vip",
"1667.50",
1254.1552631578948
],
[
248,
26,
"core",
"1663.75",
1213.0695652173913
],
[
22,
88,
"new",
"1656.25",
1078.868
],
[
486,
20,
"new",
"1655.50",
1078.868
],
[
54,
38,
"core",
"1655.25",
1213.0695652173913
],
[
427,
2,
"core",
"1655.00",
1213.0695652173913
],
[
147,
29,
"growth",
"1648.00",
1117.2432432432433
],
[
349,
13,
"growth",
"1646.50",
1117.2432432432433
],
[
223,
67,
"vip",
"1640.00",
1254.1552631578948
],
[
419,
21,
"growth",
"1638.50",
1117.2432432432433
],
[
216,
57,
"growth",
"1628.00",
1117.2432432432433
],
[
42,
12,
"new",
"1624.25",
1078.868
],
[
305,
53,
"growth",
"1621.75",
1117.2432432432433
],
[
586,
33,
"growth",
"1616.00",
1117.2432432432433
],
[
292,
65,
"growth",
"1609.75",
1117.2432432432433
],
[
328,
83,
"vip",
"1607.00",
1254.1552631578948
],
[
5,
55,
"vip",
"1589.50",
1254.1552631578948
],
[
495,
74,
"core",
"1587.00",
1213.0695652173913
],
[
589,
24,
"new",
"1584.50",
1078.868
],
[
508,
12,
"new",
"1584.25",
1078.868
],
[
154,
80,
"new",
"1581.00",
1078.868
],
[
39,
44,
"new",
"1565.00",
1078.868
],
[
123,
56,
"new",
"1561.75",
1078.868
],
[
146,
50,
"core",
"1535.75",
1213.0695652173913
],
[
246,
82,
"core",
"1522.00",
1213.0695652173913
],
[
254,
17,
"growth",
"1520.25",
1117.2432432432433
],
[
9,
104,
"new",
"1516.00",
1078.868
],
[
554,
86,
"core",
"1515.25",
1213.0695652173913
],
[
404,
58,
"core",
"1512.25",
1213.0695652173913
],
[
502,
66,
"core",
"1511.00",
1213.0695652173913
],
[
372,
67,
"vip",
"1507.50",
1254.1552631578948
],
[
409,
47,
"vip",
"1506.25",
1254.1552631578948
],
[
167,
1,
"growth",
"1501.50",
1117.2432432432433
],
[
346,
71,
"vip",
"1498.50",
1254.1552631578948
],
[
148,
95,
"vip",
"1496.75",
1254.1552631578948
],
[
399,
109,
"growth",
"1493.00",
1117.2432432432433
],
[
509,
21,
"growth",
"1492.75",
1117.2432432432433
],
[
564,
46,
"core",
"1491.25",
1213.0695652173913
],
[
267,
17,
"growth",
"1489.00",
1117.2432432432433
],
[
283,
53,
"growth",
"1487.50",
1117.2432432432433
],
[
276,
13,
"growth",
"1485.00",
1117.2432432432433
],
[
585,
100,
"new",
"1484.00",
1078.868
],
[
82,
80,
"new",
"1471.50",
1078.868
],
[
414,
13,
"growth",
"1471.00",
1117.2432432432433
],
[
387,
12,
"new",
"1468.75",
1078.868
],
[
103,
95,
"vip",
"1464.25",
1254.1552631578948
],
[
343,
84,
"new",
"1462.50",
1078.868
],
[
77,
41,
"growth",
"1458.25",
1117.2432432432433
],
[
174,
35,
"vip",
"1458.00",
1254.1552631578948
],
[
518,
43,
"vip",
"1450.50",
1254.1552631578948
],
[
199,
92,
"new",
"1449.50",
1078.868
],
[
106,
78,
"core",
"1442.25",
1213.0695652173913
],
[
306,
104,
"new",
"1438.25",
1078.868
],
[
402,
110,
"core",
"1421.25",
1213.0695652173913
],
[
546,
83,
"vip",
"1419.50",
1254.1552631578948
],
[
478,
96,
"new",
"1415.00",
1078.868
],
[
215,
71,
"vip",
"1411.50",
1254.1552631578948
],
[
567,
48,
"new",
"1409.50",
1078.868
],
[
514,
9,
"growth",
"1397.00",
1117.2432432432433
],
[
575,
55,
"vip",
"1392.50",
1254.1552631578948
],
[
52,
90,
"core",
"1376.75",
1213.0695652173913
],
[
438,
34,
"core",
"1373.00",
1213.0695652173913
],
[
542,
31,
"vip",
"1372.50",
1254.1552631578948
],
[
243,
92,
"new",
"1371.50",
1078.868
],
[
294,
10,
"core",
"1370.00",
1213.0695652173913
],
[
339,
81,
"growth",
"1368.75",
1117.2432432432433
],
[
537,
93,
"growth",
"1363.25",
1117.2432432432433
],
[
293,
59,
"vip",
"1361.25",
1254.1552631578948
],
[
453,
108,
"new",
"1359.50",
1078.868
],
[
449,
97,
"growth",
"1357.00",
1117.2432432432433
],
[
477,
24,
"new",
"1355.25",
1078.868
],
[
573,
67,
"vip",
"1351.00",
1254.1552631578948
],
[
14,
69,
"growth",
"1350.00",
1117.2432432432433
],
[
364,
53,
"growth",
"1349.25",
1117.2432432432433
],
[
594,
41,
"growth",
"1345.50",
1117.2432432432433
],
[
568,
84,
"new",
"1343.00",
1078.868
],
[
463,
107,
"vip",
"1342.25",
1254.1552631578948
],
[
299,
29,
"growth",
"1341.50",
1117.2432432432433
]
]
}{
"visible_summary": "返回金额高于其客户分群已完成订单平均金额的已完成订单,并按订单金额降序、订单 ID 升序排列。",
"error_code": null,
"error_message": null,
"expected_digest": "9ff6d9203b1fe6cbdc9b4682f3a261e1ec9b367d85dd1e6c1256fc6d56144ed0",
"actual_digest": "7c32b1ee8a3f5ebde7ffe5380537bb7f0e336db813586a2194f0006dcc416ff3",
"assumptions": null
}按全局事件序号排列,保留时间、级别、类型、消息和 payload。
SEQ 73case.startedinfo{
"status": "generating"
}SEQ 74prompt.builtinfo{
"status": "completed"
}SEQ 75provider.requestedinfo{
"isolation_policy_hash": "fc37781752a4ab6f4ced846844f397a0bb6084032b5e0eb7059c83e9a9bf0e8f",
"status": "running"
}SEQ 76provider.deltainfo{
"text": "{\"sql\":\"SELECT\\n o.order_id,\\n o.customer_id,\\n c.segment,\\n o.total_amount,\\n (\\n SELECT AVG(o2.total_amount)\\n FROM fact_orders AS o2\\n JOIN dim_customers AS c2\\n ON o2.customer_id = c2.customer_id\\n WHERE o2.status = 'completed'\\n AND c2.segment = c.segment\\n ) AS segment_avg_amount\\nFROM fact_orders AS o\\nJOIN dim_customers AS c\\n ON o.customer_id = c.customer_id\\nWHERE o.status = 'completed'\\n AND o.total_amount > (\\n SELECT AVG(o3.total_amount)\\n FROM fact_orders AS o3\\n JOIN dim_customers AS c3\\n ON o3.customer_id = c3.customer_id\\n WHERE o3.status = 'completed'\\n AND c3.segment = c.segment\\n )\\nORDER BY o.total_amount DESC, o.order_id ASC;\",\"summary\":\"返回金额高于其客户分群已完成订单平均金额的已完成订单,并按订单金额降序、订单 ID 升序排列。\",\"assumptions\":[\"订单金额使用 fact_orders.total_amount。\",\"分群平均金额按该分群全部已完成订单计算,每个订单计入一次。\"]}"
}SEQ 77provider.completedinfo{
"elapsed_ms": 20707.624750000832,
"status": "completed",
"token_usage": {
"cache_write_input_tokens": 0,
"cached_input_tokens": 9984,
"input_tokens": 19142,
"output_tokens": 353,
"reasoning_output_tokens": 64
}
}SEQ 78sql.parsedinfo{
"status": "completed"
}SEQ 79score.completedinfo{
"score": 100,
"status": "completed"
}完整 JSON 字段,不经过页面裁剪。
{
"actual_digest": "7c32b1ee8a3f5ebde7ffe5380537bb7f0e336db813586a2194f0006dcc416ff3",
"assumptions": null,
"attempt": 1,
"category": "subquery",
"comparison": {
"abs_tolerance": "0.005",
"decimal_scale": 2,
"duplicate_policy": "multiset",
"max_rows": 10000,
"rel_tolerance": "0",
"row_order_significant": true
},
"difficulty": "hard",
"error_code": null,
"error_message": null,
"execution_ms": 476.7052919996786,
"expected_digest": "9ff6d9203b1fe6cbdc9b4682f3a261e1ec9b367d85dd1e6c1256fc6d56144ed0",
"expected_result_preview": {
"columns": [
{
"name": "order_id",
"type": "BIGINT"
},
{
"name": "customer_id",
"type": "BIGINT"
},
{
"name": "segment",
"type": "VARCHAR"
},
{
"name": "total_amount",
"type": "DECIMAL(14,2)"
},
{
"name": "segment_avg_amount",
"type": "DOUBLE"
}
],
"digest": "9ff6d9203b1fe6cbdc9b4682f3a261e1ec9b367d85dd1e6c1256fc6d56144ed0",
"row_count": 232,
"rows": [
[
162,
70,
"core",
"3834.75",
"1213.07"
],
[
413,
46,
"core",
"3468.75",
"1213.07"
],
[
598,
39,
"vip",
"3425.75",
"1254.16"
],
[
234,
109,
"growth",
"3290.25",
"1117.24"
],
[
599,
107,
"vip",
"3282.50",
"1254.16"
],
[
562,
59,
"vip",
"3278.25",
"1254.16"
],
[
157,
2,
"core",
"3065.50",
"1213.07"
],
[
497,
78,
"core",
"3039.75",
"1213.07"
],
[
529,
95,
"vip",
"3037.25",
"1254.16"
],
[
94,
80,
"new",
"3035.50",
"1078.87"
],
[
315,
65,
"growth",
"3006.75",
"1117.24"
],
[
423,
20,
"new",
"2991.50",
"1078.87"
],
[
135,
29,
"growth",
"2926.25",
"1117.24"
],
[
532,
85,
"growth",
"2868.25",
"1117.24"
],
[
287,
80,
"new",
"2831.00",
"1078.87"
],
[
133,
89,
"growth",
"2799.00",
"1117.24"
],
[
93,
44,
"new",
"2775.50",
"1078.87"
],
[
36,
65,
"growth",
"2756.25",
"1117.24"
],
[
242,
5,
"growth",
"2751.75",
"1117.24"
],
[
44,
59,
"vip",
"2743.00",
"1254.16"
],
[
396,
74,
"core",
"2737.25",
"1213.07"
],
[
365,
107,
"vip",
"2710.00",
"1254.16"
],
[
238,
14,
"core",
"2697.00",
"1213.07"
],
[
198,
10,
"core",
"2665.75",
"1213.07"
],
[
117,
92,
"new",
"2587.75",
"1078.87"
],
[
403,
43,
"vip",
"2573.00",
"1254.16"
],
[
468,
34,
"core",
"2459.50",
"1213.07"
],
[
194,
104,
"new",
"2419.00",
"1078.87"
],
[
255,
17,
"growth",
"2417.25",
"1117.24"
],
[
327,
43,
"vip",
"2405.75",
"1254.16"
],
[
206,
63,
"vip",
"2372.00",
"1254.16"
],
[
228,
56,
"new",
"2371.75",
"1078.87"
],
[
503,
44,
"new",
"2363.25",
"1078.87"
],
[
587,
85,
"growth",
"2334.50",
"1117.24"
],
[
556,
98,
"core",
"2318.00",
"1213.07"
],
[
38,
95,
"vip",
"2307.75",
"1254.16"
],
[
545,
2,
"core",
"2307.25",
"1213.07"
],
[
144,
38,
"core",
"2272.25",
"1213.07"
],
[
526,
27,
"vip",
"2269.75",
"1254.16"
],
[
368,
45,
"growth",
"2257.25",
"1117.24"
],
[
105,
19,
"vip",
"2244.75",
"1254.16"
],
[
356,
44,
"new",
"2234.00",
"1078.87"
],
[
395,
1,
"growth",
"2230.25",
"1117.24"
],
[
374,
61,
"growth",
"2220.75",
"1117.24"
],
[
183,
82,
"core",
"2219.25",
"1213.07"
],
[
512,
72,
"new",
"2211.75",
"1078.87"
],
[
65,
61,
"growth",
"2208.75",
"1117.24"
],
[
444,
69,
"growth",
"2185.50",
"1117.24"
],
[
202,
109,
"growth",
"2177.25",
"1117.24"
],
[
27,
85,
"growth",
"2174.50",
"1117.24"
],
[
597,
94,
"core",
"2167.75",
"1213.07"
],
[
434,
91,
"vip",
"2164.50",
"1254.16"
],
[
145,
31,
"vip",
"2161.50",
"1254.16"
],
[
134,
52,
"new",
"2158.25",
"1078.87"
],
[
506,
21,
"growth",
"2151.50",
"1117.24"
],
[
386,
39,
"vip",
"2137.25",
"1254.16"
],
[
272,
32,
"new",
"2114.75",
"1078.87"
],
[
258,
82,
"core",
"2108.00",
"1213.07"
],
[
62,
50,
"core",
"2106.25",
"1213.07"
],
[
227,
50,
"core",
"2095.50",
"1213.07"
],
[
324,
21,
"growth",
"2077.75",
"1117.24"
],
[
159,
34,
"core",
"2060.50",
"1213.07"
],
[
447,
38,
"core",
"2050.25",
"1213.07"
],
[
377,
106,
"core",
"2049.75",
"1213.07"
],
[
279,
40,
"new",
"2018.50",
"1078.87"
],
[
132,
17,
"growth",
"2007.50",
"1117.24"
],
[
98,
21,
"growth",
"1982.25",
"1117.24"
],
[
68,
13,
"growth",
"1975.75",
"1117.24"
],
[
266,
58,
"core",
"1969.00",
"1213.07"
],
[
452,
42,
"core",
"1968.75",
"1213.07"
],
[
172,
62,
"core",
"1968.00",
"1213.07"
],
[
298,
94,
"core",
"1951.25",
"1213.07"
],
[
469,
97,
"growth",
"1936.50",
"1117.24"
],
[
406,
51,
"vip",
"1933.50",
"1254.16"
],
[
257,
31,
"vip",
"1930.25",
"1254.16"
],
[
107,
66,
"core",
"1924.50",
"1213.07"
],
[
392,
96,
"new",
"1922.25",
"1078.87"
],
[
143,
60,
"new",
"1922.00",
"1078.87"
],
[
63,
94,
"core",
"1911.25",
"1213.07"
],
[
47,
24,
"new",
"1908.50",
"1078.87"
],
[
274,
89,
"growth",
"1891.50",
"1117.24"
],
[
523,
60,
"new",
"1890.50",
"1078.87"
],
[
504,
107,
"vip",
"1890.00",
"1254.16"
],
[
57,
105,
"growth",
"1888.25",
"1117.24"
],
[
252,
13,
"growth",
"1875.75",
"1117.24"
],
[
73,
46,
"core",
"1856.50",
"1213.07"
],
[
375,
49,
"growth",
"1846.75",
"1117.24"
],
[
472,
71,
"vip",
"1846.25",
"1254.16"
],
[
127,
51,
"vip",
"1817.50",
"1254.16"
],
[
383,
32,
"new",
"1816.75",
"1078.87"
],
[
393,
6,
"core",
"1809.25",
"1213.07"
],
[
566,
104,
"new",
"1799.25",
"1078.87"
],
[
334,
14,
"core",
"1798.50",
"1213.07"
],
[
129,
93,
"growth",
"1798.00",
"1117.24"
],
[
192,
76,
"new",
"1793.75",
"1078.87"
],
[
578,
104,
"new",
"1791.00",
"1078.87"
],
[
388,
15,
"vip",
"1789.75",
"1254.16"
],
[
549,
10,
"core",
"1789.75",
"1213.07"
],
[
49,
14,
"core",
"1789.00",
"1213.07"
],
[
397,
67,
"vip",
"1785.00",
"1254.16"
],
[
213,
28,
"new",
"1780.75",
"1078.87"
],
[
323,
85,
"growth",
"1780.50",
"1117.24"
],
[
405,
79,
"vip",
"1774.50",
"1254.16"
],
[
95,
15,
"vip",
"1770.50",
"1254.16"
],
[
338,
35,
"vip",
"1760.75",
"1254.16"
],
[
422,
79,
"vip",
"1758.00",
"1254.16"
],
[
459,
106,
"core",
"1756.75",
"1213.07"
],
[
112,
17,
"growth",
"1742.50",
"1117.24"
],
[
3,
48,
"new",
"1735.00",
"1078.87"
],
[
177,
93,
"growth",
"1732.50",
"1117.24"
],
[
335,
22,
"core",
"1727.00",
"1213.07"
],
[
55,
69,
"growth",
"1714.25",
"1117.24"
],
[
6,
31,
"vip",
"1713.50",
"1254.16"
],
[
229,
12,
"new",
"1696.75",
"1078.87"
],
[
138,
64,
"new",
"1695.25",
"1078.87"
],
[
296,
48,
"new",
"1692.00",
"1078.87"
],
[
336,
61,
"growth",
"1691.75",
"1117.24"
],
[
179,
110,
"core",
"1690.25",
"1213.07"
],
[
193,
67,
"vip",
"1683.75",
"1254.16"
],
[
89,
108,
"new",
"1676.75",
"1078.87"
],
[
4,
32,
"new",
"1676.25",
"1078.87"
],
[
424,
56,
"new",
"1670.75",
"1078.87"
],
[
369,
35,
"vip",
"1667.50",
"1254.16"
],
[
248,
26,
"core",
"1663.75",
"1213.07"
],
[
22,
88,
"new",
"1656.25",
"1078.87"
],
[
486,
20,
"new",
"1655.50",
"1078.87"
],
[
54,
38,
"core",
"1655.25",
"1213.07"
],
[
427,
2,
"core",
"1655.00",
"1213.07"
],
[
147,
29,
"growth",
"1648.00",
"1117.24"
],
[
349,
13,
"growth",
"1646.50",
"1117.24"
],
[
223,
67,
"vip",
"1640.00",
"1254.16"
],
[
419,
21,
"growth",
"1638.50",
"1117.24"
],
[
216,
57,
"growth",
"1628.00",
"1117.24"
],
[
42,
12,
"new",
"1624.25",
"1078.87"
],
[
305,
53,
"growth",
"1621.75",
"1117.24"
],
[
586,
33,
"growth",
"1616.00",
"1117.24"
],
[
292,
65,
"growth",
"1609.75",
"1117.24"
],
[
328,
83,
"vip",
"1607.00",
"1254.16"
],
[
5,
55,
"vip",
"1589.50",
"1254.16"
],
[
495,
74,
"core",
"1587.00",
"1213.07"
],
[
589,
24,
"new",
"1584.50",
"1078.87"
],
[
508,
12,
"new",
"1584.25",
"1078.87"
],
[
154,
80,
"new",
"1581.00",
"1078.87"
],
[
39,
44,
"new",
"1565.00",
"1078.87"
],
[
123,
56,
"new",
"1561.75",
"1078.87"
],
[
146,
50,
"core",
"1535.75",
"1213.07"
],
[
246,
82,
"core",
"1522.00",
"1213.07"
],
[
254,
17,
"growth",
"1520.25",
"1117.24"
],
[
9,
104,
"new",
"1516.00",
"1078.87"
],
[
554,
86,
"core",
"1515.25",
"1213.07"
],
[
404,
58,
"core",
"1512.25",
"1213.07"
],
[
502,
66,
"core",
"1511.00",
"1213.07"
],
[
372,
67,
"vip",
"1507.50",
"1254.16"
],
[
409,
47,
"vip",
"1506.25",
"1254.16"
],
[
167,
1,
"growth",
"1501.50",
"1117.24"
],
[
346,
71,
"vip",
"1498.50",
"1254.16"
],
[
148,
95,
"vip",
"1496.75",
"1254.16"
],
[
399,
109,
"growth",
"1493.00",
"1117.24"
],
[
509,
21,
"growth",
"1492.75",
"1117.24"
],
[
564,
46,
"core",
"1491.25",
"1213.07"
],
[
267,
17,
"growth",
"1489.00",
"1117.24"
],
[
283,
53,
"growth",
"1487.50",
"1117.24"
],
[
276,
13,
"growth",
"1485.00",
"1117.24"
],
[
585,
100,
"new",
"1484.00",
"1078.87"
],
[
82,
80,
"new",
"1471.50",
"1078.87"
],
[
414,
13,
"growth",
"1471.00",
"1117.24"
],
[
387,
12,
"new",
"1468.75",
"1078.87"
],
[
103,
95,
"vip",
"1464.25",
"1254.16"
],
[
343,
84,
"new",
"1462.50",
"1078.87"
],
[
77,
41,
"growth",
"1458.25",
"1117.24"
],
[
174,
35,
"vip",
"1458.00",
"1254.16"
],
[
518,
43,
"vip",
"1450.50",
"1254.16"
],
[
199,
92,
"new",
"1449.50",
"1078.87"
],
[
106,
78,
"core",
"1442.25",
"1213.07"
],
[
306,
104,
"new",
"1438.25",
"1078.87"
],
[
402,
110,
"core",
"1421.25",
"1213.07"
],
[
546,
83,
"vip",
"1419.50",
"1254.16"
],
[
478,
96,
"new",
"1415.00",
"1078.87"
],
[
215,
71,
"vip",
"1411.50",
"1254.16"
],
[
567,
48,
"new",
"1409.50",
"1078.87"
],
[
514,
9,
"growth",
"1397.00",
"1117.24"
],
[
575,
55,
"vip",
"1392.50",
"1254.16"
],
[
52,
90,
"core",
"1376.75",
"1213.07"
],
[
438,
34,
"core",
"1373.00",
"1213.07"
],
[
542,
31,
"vip",
"1372.50",
"1254.16"
],
[
243,
92,
"new",
"1371.50",
"1078.87"
],
[
294,
10,
"core",
"1370.00",
"1213.07"
],
[
339,
81,
"growth",
"1368.75",
"1117.24"
],
[
537,
93,
"growth",
"1363.25",
"1117.24"
],
[
293,
59,
"vip",
"1361.25",
"1254.16"
],
[
453,
108,
"new",
"1359.50",
"1078.87"
],
[
449,
97,
"growth",
"1357.00",
"1117.24"
],
[
477,
24,
"new",
"1355.25",
"1078.87"
],
[
573,
67,
"vip",
"1351.00",
"1254.16"
],
[
14,
69,
"growth",
"1350.00",
"1117.24"
],
[
364,
53,
"growth",
"1349.25",
"1117.24"
],
[
594,
41,
"growth",
"1345.50",
"1117.24"
],
[
568,
84,
"new",
"1343.00",
"1078.87"
],
[
463,
107,
"vip",
"1342.25",
"1254.16"
],
[
299,
29,
"growth",
"1341.50",
"1117.24"
]
]
},
"finished_at": "2026-08-29T16:39:03.468679",
"formatted_sql": "SELECT\n o.order_id,\n o.customer_id,\n c.segment,\n o.total_amount,\n (\n SELECT\n AVG(o2.total_amount)\n FROM fact_orders AS o2\n JOIN dim_customers AS c2\n ON o2.customer_id = c2.customer_id\n WHERE\n o2.status = 'completed' AND c2.segment = c.segment\n ) AS segment_avg_amount\nFROM fact_orders AS o\nJOIN dim_customers AS c\n ON o.customer_id = c.customer_id\nWHERE\n o.status = 'completed'\n AND o.total_amount > (\n SELECT\n AVG(o3.total_amount)\n FROM fact_orders AS o3\n JOIN dim_customers AS c3\n ON o3.customer_id = c3.customer_id\n WHERE\n o3.status = 'completed' AND c3.segment = c.segment\n )\nORDER BY\n o.total_amount DESC,\n o.order_id ASC",
"generated_sql": "SELECT\n o.order_id,\n o.customer_id,\n c.segment,\n o.total_amount,\n (\n SELECT AVG(o2.total_amount)\n FROM fact_orders AS o2\n JOIN dim_customers AS c2\n ON o2.customer_id = c2.customer_id\n WHERE o2.status = 'completed'\n AND c2.segment = c.segment\n ) AS segment_avg_amount\nFROM fact_orders AS o\nJOIN dim_customers AS c\n ON o.customer_id = c.customer_id\nWHERE o.status = 'completed'\n AND o.total_amount > (\n SELECT AVG(o3.total_amount)\n FROM fact_orders AS o3\n JOIN dim_customers AS c3\n ON o3.customer_id = c3.customer_id\n WHERE o3.status = 'completed'\n AND c3.segment = c.segment\n )\nORDER BY o.total_amount DESC, o.order_id ASC;",
"generation_ms": null,
"id": 40,
"model_name": "Sol 本机实测",
"model_run_id": 13,
"plan": null,
"prompt": "你是 Text-to-SQL 生成器。只生成完成问题所需的 SQL 和简短可见摘要,不输出隐藏推理。\n\n方言与安全规则:\nUse DuckDB SQL. Return exactly one read-only query. Do not access files, URLs, extensions, or schemas outside the supplied tables.\n\n数据库结构:\n{\"semantic_relationships\":[{\"cardinality\":\"many_to_one\",\"from_entity\":\"order\",\"sql_on\":\"fact_orders.customer_id = dim_customers.customer_id\",\"to_entity\":\"customer\"},{\"cardinality\":\"many_to_one\",\"from_entity\":\"order\",\"sql_on\":\"fact_orders.channel_id = dim_channels.channel_id\",\"to_entity\":\"channel\"},{\"cardinality\":\"many_to_one\",\"from_entity\":\"order_item\",\"sql_on\":\"fact_order_items.order_id = fact_orders.order_id\",\"to_entity\":\"order\"},{\"cardinality\":\"many_to_one\",\"from_entity\":\"order_item\",\"sql_on\":\"fact_order_items.product_id = dim_products.product_id\",\"to_entity\":\"product\"},{\"cardinality\":\"many_to_one\",\"from_entity\":\"payment\",\"sql_on\":\"fact_payments.order_id = fact_orders.order_id\",\"to_entity\":\"order\"},{\"cardinality\":\"many_to_one\",\"from_entity\":\"return\",\"sql_on\":\"fact_returns.order_id = fact_order_items.order_id AND fact_returns.line_no = fact_order_items.line_no\",\"to_entity\":\"order_item\"}],\"tables\":[{\"columns\":[{\"data_type\":\"BIGINT\",\"name\":\"channel_id\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"channel_name\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"channel_type\",\"nullable\":false}],\"foreign_keys\":[],\"name\":\"dim_channels\",\"primary_key\":[\"channel_id\"]},{\"columns\":[{\"data_type\":\"BIGINT\",\"name\":\"customer_id\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"customer_name\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"city\",\"nullable\":true},{\"data_type\":\"DATE\",\"name\":\"signup_date\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"segment\",\"nullable\":false}],\"foreign_keys\":[],\"name\":\"dim_customers\",\"primary_key\":[\"customer_id\"]},{\"columns\":[{\"data_type\":\"BIGINT\",\"name\":\"product_id\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"product_name\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"category\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"brand\",\"nullable\":false},{\"data_type\":\"DECIMAL(14,2)\",\"name\":\"list_price\",\"nullable\":false}],\"foreign_keys\":[],\"name\":\"dim_products\",\"primary_key\":[\"product_id\"]},{\"columns\":[{\"data_type\":\"BIGINT\",\"name\":\"order_id\",\"nullable\":false},{\"data_type\":\"BIGINT\",\"name\":\"line_no\",\"nullable\":false},{\"data_type\":\"BIGINT\",\"name\":\"product_id\",\"nullable\":false},{\"data_type\":\"BIGINT\",\"name\":\"quantity\",\"nullable\":false},{\"data_type\":\"DECIMAL(14,2)\",\"name\":\"unit_price\",\"nullable\":false},{\"data_type\":\"DECIMAL(14,2)\",\"name\":\"discount_amount\",\"nullable\":false}],\"foreign_keys\":[{\"columns\":[\"order_id\"],\"referenced_columns\":[\"order_id\"],\"referenced_table\":\"fact_orders\"},{\"columns\":[\"product_id\"],\"referenced_columns\":[\"product_id\"],\"referenced_table\":\"dim_products\"}],\"name\":\"fact_order_items\",\"primary_key\":[\"order_id\",\"line_no\"]},{\"columns\":[{\"data_type\":\"BIGINT\",\"name\":\"order_id\",\"nullable\":false},{\"data_type\":\"BIGINT\",\"name\":\"customer_id\",\"nullable\":false},{\"data_type\":\"BIGINT\",\"name\":\"channel_id\",\"nullable\":false},{\"data_type\":\"DATE\",\"name\":\"order_date\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"status\",\"nullable\":false},{\"data_type\":\"DECIMAL(14,2)\",\"name\":\"total_amount\",\"nullable\":false}],\"foreign_keys\":[{\"columns\":[\"customer_id\"],\"referenced_columns\":[\"customer_id\"],\"referenced_table\":\"dim_customers\"},{\"columns\":[\"channel_id\"],\"referenced_columns\":[\"channel_id\"],\"referenced_table\":\"dim_channels\"}],\"name\":\"fact_orders\",\"primary_key\":[\"order_id\"]},{\"columns\":[{\"data_type\":\"BIGINT\",\"name\":\"payment_id\",\"nullable\":false},{\"data_type\":\"BIGINT\",\"name\":\"order_id\",\"nullable\":false},{\"data_type\":\"TIMESTAMP\",\"name\":\"paid_at\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"payment_method\",\"nullable\":false},{\"data_type\":\"DECIMAL(14,2)\",\"name\":\"amount\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"status\",\"nullable\":false}],\"foreign_keys\":[{\"columns\":[\"order_id\"],\"referenced_columns\":[\"order_id\"],\"referenced_table\":\"fact_orders\"}],\"name\":\"fact_payments\",\"primary_key\":[\"payment_id\"]},{\"columns\":[{\"data_type\":\"BIGINT\",\"name\":\"return_id\",\"nullable\":false},{\"data_type\":\"BIGINT\",\"name\":\"order_id\",\"nullable\":false},{\"data_type\":\"BIGINT\",\"name\":\"line_no\",\"nullable\":false},{\"data_type\":\"TIMESTAMP\",\"name\":\"returned_at\",\"nullable\":false},{\"data_type\":\"BIGINT\",\"name\":\"return_qty\",\"nullable\":false},{\"data_type\":\"DECIMAL(14,2)\",\"name\":\"refund_amount\",\"nullable\":false},{\"data_type\":\"VARCHAR\",\"name\":\"reason\",\"nullable\":true}],\"foreign_keys\":[{\"columns\":[\"order_id\",\"line_no\"],\"referenced_columns\":[\"order_id\",\"line_no\"],\"referenced_table\":\"fact_order_items\"}],\"name\":\"fact_returns\",\"primary_key\":[\"return_id\"]}]}\n\n语义层与业务口径:\n{\"business_rules\":[\"完成订单仅指 fact_orders.status = 'completed'。\",\"净销售额为 quantity * unit_price - discount_amount。\",\"paid、refunded、failed 金额只按 fact_payments.status 分类。\",\"退货率为完成订单的 returned_qty / sold_qty,售出数量仅含完成订单。\",\"月份按 UTC Gregorian calendar 计算。\"],\"dimensions\":[{\"data_type\":\"VARCHAR\",\"description\":\"客户分群\",\"expression\":\"dim_customers.segment\",\"name\":\"customer_segment\"},{\"data_type\":\"VARCHAR\",\"description\":\"商品品类\",\"expression\":\"dim_products.category\",\"name\":\"product_category\"},{\"data_type\":\"VARCHAR\",\"description\":\"渠道类型\",\"expression\":\"dim_channels.channel_type\",\"name\":\"channel_type\"},{\"data_type\":\"VARCHAR\",\"description\":\"UTC Gregorian 月份\",\"expression\":\"strftime(fact_orders.order_date, '%Y-%m')\",\"name\":\"order_month\"}],\"entities\":[{\"description\":\"客户主数据\",\"grain\":\"每行一个客户\",\"name\":\"customer\",\"primary_key\":[\"customer_id\"],\"table\":\"dim_customers\"},{\"description\":\"商品主数据\",\"grain\":\"每行一个商品\",\"name\":\"product\",\"primary_key\":[\"product_id\"],\"table\":\"dim_products\"},{\"description\":\"渠道主数据\",\"grain\":\"每行一个渠道\",\"name\":\"channel\",\"primary_key\":[\"channel_id\"],\"table\":\"dim_channels\"},{\"description\":\"订单头\",\"grain\":\"每行一个订单\",\"name\":\"order\",\"primary_key\":[\"order_id\"],\"table\":\"fact_orders\"},{\"description\":\"订单行\",\"grain\":\"每行一个订单商品行\",\"name\":\"order_item\",\"primary_key\":[\"order_id\",\"line_no\"],\"table\":\"fact_order_items\"},{\"description\":\"支付尝试\",\"grain\":\"每行一笔支付\",\"name\":\"payment\",\"primary_key\":[\"payment_id\"],\"table\":\"fact_payments\"},{\"description\":\"退货记录\",\"grain\":\"每行一条订单行退货\",\"name\":\"return\",\"primary_key\":[\"return_id\"],\"table\":\"fact_returns\"}],\"metrics\":[{\"description\":\"已完成订单数\",\"expression\":\"COUNT(DISTINCT CASE WHEN fact_orders.status = 'completed' THEN fact_orders.order_id END)\",\"filters\":[\"fact_orders.status = 'completed'\"],\"grain\":\"聚合\",\"name\":\"completed_order_count\"},{\"description\":\"完成订单商品行净销售额\",\"expression\":\"SUM(fact_order_items.quantity * fact_order_items.unit_price - fact_order_items.discount_amount)\",\"filters\":[\"fact_orders.status = 'completed'\"],\"grain\":\"聚合\",\"name\":\"net_revenue\"},{\"description\":\"成功支付金额\",\"expression\":\"SUM(CASE WHEN fact_payments.status = 'paid' THEN fact_payments.amount ELSE 0 END)\",\"filters\":[],\"grain\":\"聚合\",\"name\":\"paid_amount\"},{\"description\":\"退款状态支付金额\",\"expression\":\"SUM(CASE WHEN fact_payments.status = 'refunded' THEN fact_payments.amount ELSE 0 END)\",\"filters\":[],\"grain\":\"聚合\",\"name\":\"refunded_amount\"},{\"description\":\"失败支付金额\",\"expression\":\"SUM(CASE WHEN fact_payments.status = 'failed' THEN fact_payments.amount ELSE 0 END)\",\"filters\":[],\"grain\":\"聚合\",\"name\":\"failed_amount\"},{\"description\":\"完成订单退货数量除以售出数量\",\"expression\":\"SUM(fact_returns.return_qty) / SUM(fact_order_items.quantity)\",\"filters\":[\"fact_orders.status = 'completed'\"],\"grain\":\"聚合\",\"name\":\"return_rate\"}],\"relationships\":[{\"cardinality\":\"many_to_one\",\"from_entity\":\"order\",\"sql_on\":\"fact_orders.customer_id = dim_customers.customer_id\",\"to_entity\":\"customer\"},{\"cardinality\":\"many_to_one\",\"from_entity\":\"order\",\"sql_on\":\"fact_orders.channel_id = dim_channels.channel_id\",\"to_entity\":\"channel\"},{\"cardinality\":\"many_to_one\",\"from_entity\":\"order_item\",\"sql_on\":\"fact_order_items.order_id = fact_orders.order_id\",\"to_entity\":\"order\"},{\"cardinality\":\"many_to_one\",\"from_entity\":\"order_item\",\"sql_on\":\"fact_order_items.product_id = dim_products.product_id\",\"to_entity\":\"product\"},{\"cardinality\":\"many_to_one\",\"from_entity\":\"payment\",\"sql_on\":\"fact_payments.order_id = fact_orders.order_id\",\"to_entity\":\"order\"},{\"cardinality\":\"many_to_one\",\"from_entity\":\"return\",\"sql_on\":\"fact_returns.order_id = fact_order_items.order_id AND fact_returns.line_no = fact_order_items.line_no\",\"to_entity\":\"order_item\"}]}\n\n问题:\n找出金额高于同客户分群已完成订单平均金额的已完成订单,输出 order_id、customer_id、segment、total_amount、segment_avg_amount,并按 total_amount 降序、order_id 升序;必须使用外层引用的相关子查询。\n\n输出必须严格匹配此 JSON Schema:\n{\"additionalProperties\":false,\"properties\":{\"assumptions\":{\"items\":{\"type\":\"string\"},\"title\":\"Assumptions\",\"type\":\"array\"},\"sql\":{\"title\":\"Sql\",\"type\":\"string\"},\"summary\":{\"title\":\"Summary\",\"type\":\"string\"}},\"required\":[\"sql\",\"summary\",\"assumptions\"],\"title\":\"GenerationOutput\",\"type\":\"object\"}",
"provider_request_id": null,
"question": "找出金额高于同客户分群已完成订单平均金额的已完成订单,输出 order_id、customer_id、segment、total_amount、segment_avg_amount,并按 total_amount 降序、order_id 升序;必须使用外层引用的相关子查询。",
"radar_dimension": "子查询",
"raw_output": "{\"sql\":\"SELECT\\n o.order_id,\\n o.customer_id,\\n c.segment,\\n o.total_amount,\\n (\\n SELECT AVG(o2.total_amount)\\n FROM fact_orders AS o2\\n JOIN dim_customers AS c2\\n ON o2.customer_id = c2.customer_id\\n WHERE o2.status = 'completed'\\n AND c2.segment = c.segment\\n ) AS segment_avg_amount\\nFROM fact_orders AS o\\nJOIN dim_customers AS c\\n ON o.customer_id = c.customer_id\\nWHERE o.status = 'completed'\\n AND o.total_amount > (\\n SELECT AVG(o3.total_amount)\\n FROM fact_orders AS o3\\n JOIN dim_customers AS c3\\n ON o3.customer_id = c3.customer_id\\n WHERE o3.status = 'completed'\\n AND c3.segment = c.segment\\n )\\nORDER BY o.total_amount DESC, o.order_id ASC;\",\"summary\":\"返回金额高于其客户分群已完成订单平均金额的已完成订单,并按订单金额降序、订单 ID 升序排列。\",\"assumptions\":[\"订单金额使用 fact_orders.total_amount。\",\"分群平均金额按该分群全部已完成订单计算,每个订单计入一次。\"]}",
"reference_sql": "SELECT o.order_id, o.customer_id, c.segment, o.total_amount, a.segment_avg_amount FROM fact_orders o JOIN dim_customers c ON c.customer_id = o.customer_id JOIN LATERAL (SELECT ROUND(AVG(o2.total_amount), 2) AS segment_avg_amount FROM fact_orders o2 JOIN dim_customers c2 ON c2.customer_id = o2.customer_id WHERE o2.status = 'completed' AND c2.segment = c.segment) a ON TRUE WHERE o.status = 'completed' AND o.total_amount > a.segment_avg_amount ORDER BY o.total_amount DESC, o.order_id ASC",
"requested_model_id": "gpt-5.6-sol",
"required_ast": [
{
"id": "correlated",
"kind": "correlated_subquery",
"min": 1
}
],
"resolved_model_id": "gpt-5.6-sol",
"result_preview": {
"columns": [
{
"name": "order_id",
"type": "BIGINT"
},
{
"name": "customer_id",
"type": "BIGINT"
},
{
"name": "segment",
"type": "VARCHAR"
},
{
"name": "total_amount",
"type": "DECIMAL(14,2)"
},
{
"name": "segment_avg_amount",
"type": "DOUBLE"
}
],
"extra": [],
"missing": [],
"row_count": 232,
"rows": [
[
162,
70,
"core",
"3834.75",
1213.0695652173913
],
[
413,
46,
"core",
"3468.75",
1213.0695652173913
],
[
598,
39,
"vip",
"3425.75",
1254.1552631578948
],
[
234,
109,
"growth",
"3290.25",
1117.2432432432433
],
[
599,
107,
"vip",
"3282.50",
1254.1552631578948
],
[
562,
59,
"vip",
"3278.25",
1254.1552631578948
],
[
157,
2,
"core",
"3065.50",
1213.0695652173913
],
[
497,
78,
"core",
"3039.75",
1213.0695652173913
],
[
529,
95,
"vip",
"3037.25",
1254.1552631578948
],
[
94,
80,
"new",
"3035.50",
1078.868
],
[
315,
65,
"growth",
"3006.75",
1117.2432432432433
],
[
423,
20,
"new",
"2991.50",
1078.868
],
[
135,
29,
"growth",
"2926.25",
1117.2432432432433
],
[
532,
85,
"growth",
"2868.25",
1117.2432432432433
],
[
287,
80,
"new",
"2831.00",
1078.868
],
[
133,
89,
"growth",
"2799.00",
1117.2432432432433
],
[
93,
44,
"new",
"2775.50",
1078.868
],
[
36,
65,
"growth",
"2756.25",
1117.2432432432433
],
[
242,
5,
"growth",
"2751.75",
1117.2432432432433
],
[
44,
59,
"vip",
"2743.00",
1254.1552631578948
],
[
396,
74,
"core",
"2737.25",
1213.0695652173913
],
[
365,
107,
"vip",
"2710.00",
1254.1552631578948
],
[
238,
14,
"core",
"2697.00",
1213.0695652173913
],
[
198,
10,
"core",
"2665.75",
1213.0695652173913
],
[
117,
92,
"new",
"2587.75",
1078.868
],
[
403,
43,
"vip",
"2573.00",
1254.1552631578948
],
[
468,
34,
"core",
"2459.50",
1213.0695652173913
],
[
194,
104,
"new",
"2419.00",
1078.868
],
[
255,
17,
"growth",
"2417.25",
1117.2432432432433
],
[
327,
43,
"vip",
"2405.75",
1254.1552631578948
],
[
206,
63,
"vip",
"2372.00",
1254.1552631578948
],
[
228,
56,
"new",
"2371.75",
1078.868
],
[
503,
44,
"new",
"2363.25",
1078.868
],
[
587,
85,
"growth",
"2334.50",
1117.2432432432433
],
[
556,
98,
"core",
"2318.00",
1213.0695652173913
],
[
38,
95,
"vip",
"2307.75",
1254.1552631578948
],
[
545,
2,
"core",
"2307.25",
1213.0695652173913
],
[
144,
38,
"core",
"2272.25",
1213.0695652173913
],
[
526,
27,
"vip",
"2269.75",
1254.1552631578948
],
[
368,
45,
"growth",
"2257.25",
1117.2432432432433
],
[
105,
19,
"vip",
"2244.75",
1254.1552631578948
],
[
356,
44,
"new",
"2234.00",
1078.868
],
[
395,
1,
"growth",
"2230.25",
1117.2432432432433
],
[
374,
61,
"growth",
"2220.75",
1117.2432432432433
],
[
183,
82,
"core",
"2219.25",
1213.0695652173913
],
[
512,
72,
"new",
"2211.75",
1078.868
],
[
65,
61,
"growth",
"2208.75",
1117.2432432432433
],
[
444,
69,
"growth",
"2185.50",
1117.2432432432433
],
[
202,
109,
"growth",
"2177.25",
1117.2432432432433
],
[
27,
85,
"growth",
"2174.50",
1117.2432432432433
],
[
597,
94,
"core",
"2167.75",
1213.0695652173913
],
[
434,
91,
"vip",
"2164.50",
1254.1552631578948
],
[
145,
31,
"vip",
"2161.50",
1254.1552631578948
],
[
134,
52,
"new",
"2158.25",
1078.868
],
[
506,
21,
"growth",
"2151.50",
1117.2432432432433
],
[
386,
39,
"vip",
"2137.25",
1254.1552631578948
],
[
272,
32,
"new",
"2114.75",
1078.868
],
[
258,
82,
"core",
"2108.00",
1213.0695652173913
],
[
62,
50,
"core",
"2106.25",
1213.0695652173913
],
[
227,
50,
"core",
"2095.50",
1213.0695652173913
],
[
324,
21,
"growth",
"2077.75",
1117.2432432432433
],
[
159,
34,
"core",
"2060.50",
1213.0695652173913
],
[
447,
38,
"core",
"2050.25",
1213.0695652173913
],
[
377,
106,
"core",
"2049.75",
1213.0695652173913
],
[
279,
40,
"new",
"2018.50",
1078.868
],
[
132,
17,
"growth",
"2007.50",
1117.2432432432433
],
[
98,
21,
"growth",
"1982.25",
1117.2432432432433
],
[
68,
13,
"growth",
"1975.75",
1117.2432432432433
],
[
266,
58,
"core",
"1969.00",
1213.0695652173913
],
[
452,
42,
"core",
"1968.75",
1213.0695652173913
],
[
172,
62,
"core",
"1968.00",
1213.0695652173913
],
[
298,
94,
"core",
"1951.25",
1213.0695652173913
],
[
469,
97,
"growth",
"1936.50",
1117.2432432432433
],
[
406,
51,
"vip",
"1933.50",
1254.1552631578948
],
[
257,
31,
"vip",
"1930.25",
1254.1552631578948
],
[
107,
66,
"core",
"1924.50",
1213.0695652173913
],
[
392,
96,
"new",
"1922.25",
1078.868
],
[
143,
60,
"new",
"1922.00",
1078.868
],
[
63,
94,
"core",
"1911.25",
1213.0695652173913
],
[
47,
24,
"new",
"1908.50",
1078.868
],
[
274,
89,
"growth",
"1891.50",
1117.2432432432433
],
[
523,
60,
"new",
"1890.50",
1078.868
],
[
504,
107,
"vip",
"1890.00",
1254.1552631578948
],
[
57,
105,
"growth",
"1888.25",
1117.2432432432433
],
[
252,
13,
"growth",
"1875.75",
1117.2432432432433
],
[
73,
46,
"core",
"1856.50",
1213.0695652173913
],
[
375,
49,
"growth",
"1846.75",
1117.2432432432433
],
[
472,
71,
"vip",
"1846.25",
1254.1552631578948
],
[
127,
51,
"vip",
"1817.50",
1254.1552631578948
],
[
383,
32,
"new",
"1816.75",
1078.868
],
[
393,
6,
"core",
"1809.25",
1213.0695652173913
],
[
566,
104,
"new",
"1799.25",
1078.868
],
[
334,
14,
"core",
"1798.50",
1213.0695652173913
],
[
129,
93,
"growth",
"1798.00",
1117.2432432432433
],
[
192,
76,
"new",
"1793.75",
1078.868
],
[
578,
104,
"new",
"1791.00",
1078.868
],
[
388,
15,
"vip",
"1789.75",
1254.1552631578948
],
[
549,
10,
"core",
"1789.75",
1213.0695652173913
],
[
49,
14,
"core",
"1789.00",
1213.0695652173913
],
[
397,
67,
"vip",
"1785.00",
1254.1552631578948
],
[
213,
28,
"new",
"1780.75",
1078.868
],
[
323,
85,
"growth",
"1780.50",
1117.2432432432433
],
[
405,
79,
"vip",
"1774.50",
1254.1552631578948
],
[
95,
15,
"vip",
"1770.50",
1254.1552631578948
],
[
338,
35,
"vip",
"1760.75",
1254.1552631578948
],
[
422,
79,
"vip",
"1758.00",
1254.1552631578948
],
[
459,
106,
"core",
"1756.75",
1213.0695652173913
],
[
112,
17,
"growth",
"1742.50",
1117.2432432432433
],
[
3,
48,
"new",
"1735.00",
1078.868
],
[
177,
93,
"growth",
"1732.50",
1117.2432432432433
],
[
335,
22,
"core",
"1727.00",
1213.0695652173913
],
[
55,
69,
"growth",
"1714.25",
1117.2432432432433
],
[
6,
31,
"vip",
"1713.50",
1254.1552631578948
],
[
229,
12,
"new",
"1696.75",
1078.868
],
[
138,
64,
"new",
"1695.25",
1078.868
],
[
296,
48,
"new",
"1692.00",
1078.868
],
[
336,
61,
"growth",
"1691.75",
1117.2432432432433
],
[
179,
110,
"core",
"1690.25",
1213.0695652173913
],
[
193,
67,
"vip",
"1683.75",
1254.1552631578948
],
[
89,
108,
"new",
"1676.75",
1078.868
],
[
4,
32,
"new",
"1676.25",
1078.868
],
[
424,
56,
"new",
"1670.75",
1078.868
],
[
369,
35,
"vip",
"1667.50",
1254.1552631578948
],
[
248,
26,
"core",
"1663.75",
1213.0695652173913
],
[
22,
88,
"new",
"1656.25",
1078.868
],
[
486,
20,
"new",
"1655.50",
1078.868
],
[
54,
38,
"core",
"1655.25",
1213.0695652173913
],
[
427,
2,
"core",
"1655.00",
1213.0695652173913
],
[
147,
29,
"growth",
"1648.00",
1117.2432432432433
],
[
349,
13,
"growth",
"1646.50",
1117.2432432432433
],
[
223,
67,
"vip",
"1640.00",
1254.1552631578948
],
[
419,
21,
"growth",
"1638.50",
1117.2432432432433
],
[
216,
57,
"growth",
"1628.00",
1117.2432432432433
],
[
42,
12,
"new",
"1624.25",
1078.868
],
[
305,
53,
"growth",
"1621.75",
1117.2432432432433
],
[
586,
33,
"growth",
"1616.00",
1117.2432432432433
],
[
292,
65,
"growth",
"1609.75",
1117.2432432432433
],
[
328,
83,
"vip",
"1607.00",
1254.1552631578948
],
[
5,
55,
"vip",
"1589.50",
1254.1552631578948
],
[
495,
74,
"core",
"1587.00",
1213.0695652173913
],
[
589,
24,
"new",
"1584.50",
1078.868
],
[
508,
12,
"new",
"1584.25",
1078.868
],
[
154,
80,
"new",
"1581.00",
1078.868
],
[
39,
44,
"new",
"1565.00",
1078.868
],
[
123,
56,
"new",
"1561.75",
1078.868
],
[
146,
50,
"core",
"1535.75",
1213.0695652173913
],
[
246,
82,
"core",
"1522.00",
1213.0695652173913
],
[
254,
17,
"growth",
"1520.25",
1117.2432432432433
],
[
9,
104,
"new",
"1516.00",
1078.868
],
[
554,
86,
"core",
"1515.25",
1213.0695652173913
],
[
404,
58,
"core",
"1512.25",
1213.0695652173913
],
[
502,
66,
"core",
"1511.00",
1213.0695652173913
],
[
372,
67,
"vip",
"1507.50",
1254.1552631578948
],
[
409,
47,
"vip",
"1506.25",
1254.1552631578948
],
[
167,
1,
"growth",
"1501.50",
1117.2432432432433
],
[
346,
71,
"vip",
"1498.50",
1254.1552631578948
],
[
148,
95,
"vip",
"1496.75",
1254.1552631578948
],
[
399,
109,
"growth",
"1493.00",
1117.2432432432433
],
[
509,
21,
"growth",
"1492.75",
1117.2432432432433
],
[
564,
46,
"core",
"1491.25",
1213.0695652173913
],
[
267,
17,
"growth",
"1489.00",
1117.2432432432433
],
[
283,
53,
"growth",
"1487.50",
1117.2432432432433
],
[
276,
13,
"growth",
"1485.00",
1117.2432432432433
],
[
585,
100,
"new",
"1484.00",
1078.868
],
[
82,
80,
"new",
"1471.50",
1078.868
],
[
414,
13,
"growth",
"1471.00",
1117.2432432432433
],
[
387,
12,
"new",
"1468.75",
1078.868
],
[
103,
95,
"vip",
"1464.25",
1254.1552631578948
],
[
343,
84,
"new",
"1462.50",
1078.868
],
[
77,
41,
"growth",
"1458.25",
1117.2432432432433
],
[
174,
35,
"vip",
"1458.00",
1254.1552631578948
],
[
518,
43,
"vip",
"1450.50",
1254.1552631578948
],
[
199,
92,
"new",
"1449.50",
1078.868
],
[
106,
78,
"core",
"1442.25",
1213.0695652173913
],
[
306,
104,
"new",
"1438.25",
1078.868
],
[
402,
110,
"core",
"1421.25",
1213.0695652173913
],
[
546,
83,
"vip",
"1419.50",
1254.1552631578948
],
[
478,
96,
"new",
"1415.00",
1078.868
],
[
215,
71,
"vip",
"1411.50",
1254.1552631578948
],
[
567,
48,
"new",
"1409.50",
1078.868
],
[
514,
9,
"growth",
"1397.00",
1117.2432432432433
],
[
575,
55,
"vip",
"1392.50",
1254.1552631578948
],
[
52,
90,
"core",
"1376.75",
1213.0695652173913
],
[
438,
34,
"core",
"1373.00",
1213.0695652173913
],
[
542,
31,
"vip",
"1372.50",
1254.1552631578948
],
[
243,
92,
"new",
"1371.50",
1078.868
],
[
294,
10,
"core",
"1370.00",
1213.0695652173913
],
[
339,
81,
"growth",
"1368.75",
1117.2432432432433
],
[
537,
93,
"growth",
"1363.25",
1117.2432432432433
],
[
293,
59,
"vip",
"1361.25",
1254.1552631578948
],
[
453,
108,
"new",
"1359.50",
1078.868
],
[
449,
97,
"growth",
"1357.00",
1117.2432432432433
],
[
477,
24,
"new",
"1355.25",
1078.868
],
[
573,
67,
"vip",
"1351.00",
1254.1552631578948
],
[
14,
69,
"growth",
"1350.00",
1117.2432432432433
],
[
364,
53,
"growth",
"1349.25",
1117.2432432432433
],
[
594,
41,
"growth",
"1345.50",
1117.2432432432433
],
[
568,
84,
"new",
"1343.00",
1078.868
],
[
463,
107,
"vip",
"1342.25",
1254.1552631578948
],
[
299,
29,
"growth",
"1341.50",
1117.2432432432433
]
]
},
"run_id": 12,
"score": {
"ast_rules": [
{
"details": {
"actual": 2,
"required": 1
},
"id": "correlated",
"kind": "correlated_subquery",
"passed": true
}
],
"column_count": 5,
"column_names": 5,
"execution": 10,
"ordering": 10,
"protocol": 5,
"read_only_ast": 5,
"row_f1": 45,
"sql_capability": 15,
"total": 100
},
"stable_key": "correlated_segment_average",
"started_at": "2026-08-29T16:38:42.192000",
"status": "completed",
"suite_content_hash": "0a4a18b4374f510f5eff18b06272c30c3375e1f082ae405adc8ead7dd9c81556",
"title": "相关子查询分群均值",
"token_usage": {
"cache_write_input_tokens": 0,
"cached_input_tokens": 9984,
"input_tokens": 19142,
"output_tokens": 353,
"reasoning_output_tokens": 64
},
"visible_summary": "返回金额高于其客户分群已完成订单平均金额的已完成订单,并按订单金额降序、订单 ID 升序排列。"
}