我已经声明了一个表变量“@t”,并正确执行了“INSERT-INTO-SELECT”。当我尝试通过一些额外的计算来查询表变量以进行每组行编号时,直接使用“@t”时出现“必须声明变量”或使用“@t”别名时出现“无效的对象名称”错误'。请多多指教。
SELECT
*,
(SELECT COUNT(*) FROM "LTV" "COUNTER"
WHERE
"COUNTER"."Collateral_ID" = "LTV"."Collateral_ID"
AND
"COUNTER"."m_il_no" = "LTV"."m_il_no"
AND
"COUNTER"."Ref_Key" <= "LTV"."Ref_Key"
GROUP BY "COUNTER"."Collateral_ID", "COUNTER"."m_il_no"
) "MIL_IDX"
FROM @t AS LTV