尝试与子查询结合时在结合中出现语法错误

时间:2019-04-02 10:09:24

标签: sql excel vba ms-access ado

使用VBA,我希望根据某些条件将一个表的选择连接到另一个表。解决方法可能很简单,但是我找不到错误。我收到运行时错误-2147217900(80040e14)“联接操作中的语法错误”。

SELECT *
FROM [target$] AS Ziel
LEFT JOIN
          (
                 SELECT *
                 FROM   [source$]
                 WHERE  [Zust].[FS] = 3
                 AND    Year([Zust].[DATUM_1A])=2018 as Zust)
ON        (
                    [Ziel].[Lage] = [Zust].[LAGE]
          AND       ((
                                        [Zust].[BKM] < [Zust].[VKM]
                              AND       [Ziel].[MitteBetrKm] <= [Zust].[VKM]
                              AND       [Ziel].[MitteBetrKm] > [Zust].[BKM])
                    OR        (
                                        [Zust].[BKM] > [Zust].[VKM]
                              AND       [Ziel].[MitteBetrKm] >= [Zust].[VKM]
                              AND       [Ziel].[MitteBetrKm] < [Zust].[BKM])))
WHERE     [Ziel].[MitteBetrKm] IS NOT NULL
ORDER BY  [Ziel].[VonKm] 

0 个答案:

没有答案