7 lines
7.9 KiB
JSON
7 lines
7.9 KiB
JSON
{"qid": "Q6", "question_zh": "所有货币的客户现金总余额是多少?", "sql": "-- 按货币统计客户现金余额\nSELECT \n CurrencyID,\n COUNT(DISTINCT AccountID) AS AccountCount,\n SUM(Settled) AS TotalSettledBalance,\n SUM(AccruedCreditInterest) AS TotalCreditInterest,\n SUM(AccruedDebitInterest) AS TotalDebitInterest,\n SUM(Settled) + SUM(AccruedCreditInterest) - SUM(AccruedDebitInterest) AS NetBalance\nFROM BCAccountCash\nGROUP BY CurrencyID\nORDER BY NetBalance DESC;", "schema_info": {"tables": {"BCAccountCash": {"alias": "BCAccountCash", "columns": []}}, "joins": []}, "explanation": "- `BCAccountCash` 记录账户现金余额\n- `Settled` 已结算余额\n- `AccruedCreditInterest` 应计存款利息\n- `AccruedDebitInterest` 应计借款利息", "question_en": "What is the total client cash balance across all currencies?", "rating": 9, "execution_result": null, "result_note": "| CurrencyID | AccountCount | TotalSettledBalance | NetBalance |\n|------------|-------------|--------------------|------------|\n| HKD | 2,906 | 52,195,305.77 | 52,195,305.77 |\n| TWD | 2 | -27,676.60 | -27,676.60 |\n| USD | 175 | 0 | 0 |\n| CNY | 95 | 0 | 0 |\n| GBP | 1 | 0 | 0 |", "tags": ["ordering", "account", "cash", "aggregation"], "difficulty": "medium"}
|
|
{"qid": "Q12", "question_zh": "本月累计的结算失败罚金是多少?", "sql": "-- 查询本月结算失败罚金 (2026年4月)\n-- 注意:BCAccountInstrument 无 FailedTradePenalty 字段,需另找结算罚金存储位置\n-- 目前未找到结算失败罚金字段,建议通过 TSBBrokerContract 或 BCBrokerCash 进一步排查\nSELECT \n COUNT(*) AS FailedTradeCount,\n MarketID\nFROM BCAccountInstrument\nWHERE YEAR(LastTransactionDate) = 2026\n AND MONTH(LastTransactionDate) = 4\nGROUP BY MarketID;", "schema_info": {"tables": {"BCAccountInstrument": {"alias": "BCAccountInstrument", "columns": []}}, "joins": []}, "explanation": "- `BCAccountInstrument` 无 `FailedTradePenalty` 字段,原始 SQL 会报错\n- `TSBBrokerContract` 或 `BCBrokerCash` 中可能存储结算相关费用,需进一步确认", "question_en": "What is the total failed trade penalty incurred this month?", "rating": 3, "execution_result": null, "result_note": "当前查询无结果(BCAccountInstrument 表无 FailedTradePenalty 字段,无法统计结算罚金)", "tags": ["filter", "aggregation"], "difficulty": "medium"}
|
|
{"qid": "Q13", "question_zh": "列出今日到期的所有股票借贷交易。", "sql": "-- 查询今日到期的股票借贷 (参考日期: 2026-04-02)\n-- MCMarket 表仅包含 HKEX/OSL/SETW,无独立借贷市场标识\n-- 股票借贷可能在持仓变动类型 HoldType 中标识,或在专门的 StockBorrowing 表中\n-- 此 SQL 按 DueBuy/DueSell 显示当前待交收证券,作为借贷合约的近似替代\nSELECT \n bi.AccountID,\n a.Name AS AccountName,\n bi.InstrumentID,\n i.Name AS InstrumentName,\n bi.DueBuy AS BorrowQuantity,\n bi.DueSell AS LoanQuantity,\n bi.DueBuy - bi.DueSell AS NetBorrow\nFROM BCAccountInstrument bi\nINNER JOIN MCAccount a ON bi.AccountID = a.AccountID\nINNER JOIN MCInstrument i ON bi.InstrumentID = i.InstrumentID\nWHERE bi.DueBuy > 0 OR bi.DueSell > 0;", "schema_info": {"tables": {"BCAccountInstrument": {"alias": "bi", "columns": []}, "MCAccount": {"alias": "a", "columns": []}, "MCInstrument": {"alias": "i", "columns": []}}, "joins": [{"type": "INNER", "on": "bi.AccountID = a.AccountID"}, {"type": "INNER", "on": "bi.InstrumentID = i.InstrumentID"}]}, "explanation": "- `DueBuy/DueSell` 表示待交收数量(借款买入/借出卖出),反映股票借贷待到期情况\n- `MCMarket` 表无 `MarketType='BORROW'` 标识,现有市场仅为 HKEX/OSL/SETW\n- 股票借贷详情可能存储在 `TSBAccountLoanContract` 或其他借贷专用表中,需业务确认", "question_en": "List all stock borrow/loan transactions due to settle today.", "rating": 5, "execution_result": null, "result_note": "当前查询无结果(BCAccountInstrument 中 DueBuy/DueSell 均为 0,无待交收证券)", "tags": ["join", "trade", "filter"], "difficulty": "medium"}
|
|
{"qid": "Q16", "question_zh": "列出T+2交易缺少结算指令的账户。", "sql": "-- 查询T+2待交收但缺少指令的账户\n-- 注意:BCAccountInstrumentInstruction 表不存在,需改用 TSBSettlementInstruction\nSELECT \n bi.AccountID,\n a.Name AS AccountName,\n bi.InstrumentID,\n i.Name AS InstrumentName,\n bi.NextDayDueBuy AS T2DueBuy,\n bi.NextDayDueSell AS T2DueSell\nFROM BCAccountInstrument bi\nINNER JOIN MCAccount a ON bi.AccountID = a.AccountID\nINNER JOIN MCInstrument i ON bi.InstrumentID = i.InstrumentID\nWHERE (bi.NextDayDueBuy > 0 OR bi.NextDayDueSell > 0)\n AND NOT EXISTS (\n SELECT 1 FROM TSBSettlementInstruction si\n WHERE si.AccountOrBrokerID = bi.AccountID\n AND si.InstrumentID = bi.InstrumentID\n AND si.State IN ('P','A')\n );", "schema_info": {"tables": {"BCAccountInstrument": {"alias": "bi", "columns": []}, "MCAccount": {"alias": "a", "columns": []}, "MCInstrument": {"alias": "i", "columns": []}, "TSBSettlementInstruction": {"alias": "si", "columns": []}}, "joins": [{"type": "INNER", "on": "bi.AccountID = a.AccountID"}, {"type": "INNER", "on": "bi.InstrumentID = i.InstrumentID"}]}, "explanation": "- `NextDayDueBuy/NextDayDueSell` T+2交收数量(次日到期)\n- `TSBSettlementInstruction` 是结算指令表,通过 `NOT EXISTS` 排除已有指令的记录\n- `BCAccountInstrumentInstruction` 表不存在,不能使用", "question_en": "Show accounts where settlement instruction is missing for T+2 trades.", "rating": 6, "execution_result": null, "result_note": "当前查询无结果", "tags": ["join", "account", "filter", "trade"], "difficulty": "medium"}
|
|
{"qid": "Q32", "question_zh": "各市场客户不同资产(如股票、债券、基金、虚拟资产)的总持仓是多少?", "sql": "-- 按市场统计客户持仓\nSELECT \n b.MarketID,\n COUNT(DISTINCT b.AccountID) AS AccountCount,\n SUM(b.Settled) AS TotalQuantity,\n SUM(b.CostAmount) AS TotalCostAmount,\n SUM(b.TotalBoughtQuantity) AS TotalBoughtQty,\n SUM(b.TotalSoldQuantity) AS TotalSoldQty\nFROM BCAccountInstrument b\nGROUP BY b.MarketID\nORDER BY TotalCostAmount DESC;", "schema_info": {"tables": {"BCAccountInstrument": {"alias": "b", "columns": []}}, "joins": []}, "explanation": "- `BCAccountInstrument` 表记录账户在各市场的持仓\n- `MarketID` 区分不同市场", "question_en": "What is the total client holding of different assets (e.g., stocks, bonds, funds, virtual assets) by each market?", "rating": 8, "execution_result": null, "result_note": "| MarketID | AccountCount | TotalQuantity | TotalCostAmount | TotalBoughtQty | TotalSoldQty |\n|----------|-------------|---------------|-----------------|---------------|-------------|\n| HKEX | 2,102 | 717,471,548 | 87,813,213.45 | 1,015,923,906 | 298,452,798 |\n| SETW | 2 | 3,100 | 32,298.50 | 4,100 | 1,000 |", "tags": ["account", "holding", "ordering", "aggregation"], "difficulty": "medium"}
|
|
{"qid": "Q36", "question_zh": "各市场(如港股T+1和T+2、美股T+1)的待结算金额是多少?", "sql": "-- 按市场统计待结算金额\nSELECT \n MarketID,\n SUM(DueBuy + DueSell) AS TotalPendingQty,\n SUM(NextDayDueBuy + NextDayDueSell) AS T2TotalPendingQty\nFROM BCAccountInstrument\nWHERE DueBuy > 0 OR DueSell > 0 OR NextDayDueBuy > 0 OR NextDayDueSell > 0\nGROUP BY MarketID;", "schema_info": {"tables": {"BCAccountInstrument": {"alias": "BCAccountInstrument", "columns": []}}, "joins": []}, "explanation": "- `BCAccountInstrument` 记录各市场的待交收数量\n- `DueBuy/DueSell` 对应T+1交收", "question_en": "What is the pending settlement amount for each market (e.g., HK T+1 & T+2, US T+1)?", "rating": 7, "execution_result": null, "result_note": "| MarketID | TotalPendingQty | T2TotalPendingQty |\n|----------|----------------|------------------|\n| HKEX | 0 | 0 |\n| SETW | 0 | 0 |", "tags": ["filter", "aggregation"], "difficulty": "medium"}
|