我正在处理一个 sql 文件,试图制作一个脚本,该脚本可以带回显示的表中的所有数据或表中的所有数据加上 3 个月的数据。我不断收到一条错误消息, error 00905 missing keyword
但我不明白为什么。
我查看了语法,这一切对我来说都是正确的。我会在它说发生错误的地方放置一个标记(在第一个内部连接处)。我更改了所有表名以使其看起来更好,因为它超出了语法。
任何帮助都会非常感谢。这只是代码的一部分,但我确信它必须在这里。
WHEN Table_typ_cde = '1' -- Pulling all data --
THEN
INNER JOIN Table acp ON Table_oid = Table_oid
INNER JOIN Table loss ON Table_oid = Table_oid
LEFT OUTER JOIN Table veh ON Table_oid = Table_oid and Table_nbr=1
INNER JOIN Table brnch ON Table_OID = Table_oid
INNER JOIN Table a ON Table_OID = Table_oid
INNER JOIN Table c Table_OID = Table_oid
INNER JOIN Table s ON Table_OID = Table_oid
INNER JOIN Table r ON Table_OID = Table_oid
INNER JOIN Table grp ON Table_oid = Table_oid
INNER JOIN Table on Table_id = Table_id
WHERE Table_ID <> 2
WHEN Table_cde = '2' -- Pulling all data within the last 3 months along with all present data --
THEN
INNER JOIN Table acp ON Table_oid = Table_oid
INNER JOIN Table loss ON Table_oid = Table_oid
LEFT OUTER JOIN Table veh ON Table_oid = Table_oid and Table_nbr=1
INNER JOIN Table brnch ON Table_OID = Table_oid
INNER JOIN Table a ON Table_OID = Table_oid
INNER JOIN Table c ON Table_OID = Table_oid
INNER JOIN Table s ON Table_OID = Table_oid
INNER JOIN Table r ON Table_OID = Table_oid
INNER JOIN Table grp ON Table_oid = Table_oid
INNER JOIN Table on Table_id = Table_id
WHERE Table_ID <> 2
AND df.DATE_CREATED BETWEEN ADD_MONTHS(SYSDATE, -6)
AND sysdate
END
) core