我正在尝试完成下面的查询,但我不断收到错误消息:
“JOIN操作中的语法错误”。
SELECT myExternalTable1.INCIDENT_ID AS INCIDENT_NR,
First(myExternalTable1.PARENTITEM) AS [COMPANY],
First(myExternalTable1.LOGGEDDATE) AS [LOGGED_DATE],
First(myExternalTable1.STATUS) AS [STATUS],
First(myExternalTable1.PRIORITY) AS [PRIORITY],
First(myExternalTable1.CATEGORY) AS [COMPLEXITY],
First(myExternalTable1.USERGROUP) AS [GROUP],
First(myExternalTable1.SPECIALISTID) AS [SPECIALIST],
First(myExternalTable1.MODULE) AS [CATEGORY],
Last(myExternalTable1.ActionDate) AS [ACTIONDATE],
First(myExternalTable1.Description) AS [DESCRIPTION],
iif([STATUS]=""Closed"" Or [STATUS]=""Cancelled"" Or [STATUS]=""Resolved"", DateDiff(""d"",LOGGED_DATE,ACTIONDATE), DateDiff(""d"",LOGGED_DATE,Date())) AS [DAYS_OPEN],
myExternalTable2.responseachieved AS [SLA_STATUS]
FROM ((myExternalTable1 IN 'K:\SOME_FOLDER\SOME_FOLDER\SOMEFOLDER\myExternalDB1.accdb')
LEFT JOIN (myExternalTable2 IN 'K:\SOME_FOLDER\SOME_FOLDER\SOMEFOLDER\myExternalDB2.accdb')
ON myExternalTable2.id = myExternalTable1.INCIDENT_ID)
WHERE (LOGGED_DATE>#12/31/2013#)
GROUP BY INCIDENT_NR
ORDER BY LOGGED_DATE;
我尝试重命名表和文件路径以保持这些秘密,同时仍保留其中使用的语法。任何帮助将不胜感激。
答案 0 :(得分:1)
SELECT met.INCIDENT_ID AS INCIDENT_NR,
First(met.PARENTITEM) AS [COMPANY],
First(met.LOGGEDDATE) AS [LOGGED_DATE],
First(met.STATUS) AS [STATUS],
First(met.PRIORITY) AS [PRIORITY],
First(met.CATEGORY) AS [COMPLEXITY],
First(met.USERGROUP) AS [GROUP],
First(met.SPECIALISTID) AS [SPECIALIST],
First(met.MODULE) AS [CATEGORY],
Last(met.ActionDate) AS [ACTIONDATE],
First(met.Description) AS [DESCRIPTION],
iif([STATUS]=""Closed"" Or [STATUS]=""Cancelled"" Or [STATUS]=""Resolved"", DateDiff(""d"",LOGGED_DATE,ACTIONDATE), DateDiff(""d"",LOGGED_DATE,Date())) AS [DAYS_OPEN],
met2.responseachieved AS [SLA_STATUS]
FROM [;database=K:\SOME_FOLDER\SOME_FOLDER\SOMEFOLDER\myExternalDB1.accdb].[myExternalTable1] AS met
LEFT JOIN [;database=K:\SOME_FOLDER\SOME_FOLDER\SOMEFOLDER\myExternalDB2.accdb].[myExternalTable2] AS met2 ON met2.id = met.INCIDENT_ID
WHERE (LOGGED_DATE>#12/31/2013#)
GROUP BY INCIDENT_NR
ORDER BY LOGGED_DATE;