0

我有下面的查询导致以下错误:

错误 3296(访问)

Join 操作中的 ON 语句不完整或包含太多表。您可能希望将 ON 表达式放在 WHERE 子句中

SELECT
    TBLCATB.Markis AS [Account #], TBLCATB.[Group Number],
    Max(TBLCATB.Name) AS [Account Name], Sum(TBLCATB.Current) AS [Current],
    Sum(TBLCATB.Thirty) AS Thirty, Sum(TBLCATB.Sixty) AS Sixty,
    Sum(TBLCATB.Ninety) AS Ninety, Max(TBLCATB.[Company Code]) AS [Company Code]
FROM
    TBLCATB
    LEFT JOIN asc_OracleMarkis
        ON CLng(TBLCATB.Markis)=asc_OracleMarkis.Markis
WHERE
    (((TBLCATB.LOB) Like "g*" Or (TBLCATB.LOB) Like "l*" Or
      (TBLCATB.LOB) Like "pb*")) AND
    CLng(tblcatb.markis) not in (select acctnumber from sb_acctinfo)
GROUP BY
    TBLCATB.Markis, TBLCATB.[Group Number]
HAVING
    (((Sum(TBLCATB.Ninety))<>0))
ORDER BY
    Sum(TBLCATB.Ninety) DESC;

我怎样才能避免这个错误?

4

3 回答 3

3

这看起来像 MS Access 语法,您缺少一个结束括号:

SELECT TBLCATB.Markis AS [Account #], 
    TBLCATB.[Group Number], 
    Max(TBLCATB.Name) AS [Account Name], 
    Sum(TBLCATB.Current) AS [Current], 
    Sum(TBLCATB.Thirty) AS Thirty, 
    Sum(TBLCATB.Sixty) AS Sixty, 
    Sum(TBLCATB.Ninety) AS Ninety, 
    Max(TBLCATB.[Company Code]) AS [Company Code]
FROM TBLCATB 
LEFT JOIN asc_OracleMarkis 
    ON CLng(TBLCATB.Markis)=asc_OracleMarkis.Markis
WHERE 
(
    (TBLCATB.LOB Like "g*" Or TBLCATB.LOB Like "l*" Or TBLCATB.LOB Like "pb*") 
    AND CLng(tblcatb.markis) not in (select acctnumber from sb_acctinfo)
) <-- this is missing
GROUP BY TBLCATB.Markis, TBLCATB.[Group Number]
HAVING Sum(TBLCATB.Ninety)<>0
ORDER BY Sum(TBLCATB.Ninety) DESC;
于 2013-01-10T16:40:31.703 回答
0

而不是使用 Clng 尝试使用 CAST 或 CONVERT

于 2013-01-10T16:51:22.767 回答
0

如果您的表是 SQL-Server 表。使您的查询成为 Pass-Through 查询并用 TSQL 语法编写。

参见:通过查询访问sql server

于 2013-01-10T17:04:12.543 回答