我只是将基于 SQL 的查询转换为在 SQL Server 上成功运行的 Access。我已将所有内容都转换为 Access 兼容格式,除了括号数有问题。我收到以下错误“来自 CLAUSE 的语法错误”,请帮助
SELECT CINT(MID(TC2.CHILDCOUNTER, 7, LEN(TC2.CHILDCOUNTER)) ) AS PKCHILDID
,tc2.VisitType
,MAX(IIf( tktResults.TaskCounter IN ( '001410' ,'001463' ,'001431' ), tktResults.Result, NULL) ) AS KWA_QuitOffered
,MAX(IIf( tktResults.TaskCounter IN ( '001411' ,'001464' ,'001432' ), tktResults.Result, NULL) ) AS KWA_QuitReferral
FROM ((tblConsultations tc2
INNER JOIN tblChild tc
ON tc2.ChildCounter = tc.ChildCounter)
LEFT JOIN tblDelivery td
ON td.ChildCounter = tc.ChildCounter)
LEFT JOIN (
SELECT ttr.ResultCounter
,ttr.ChildCounter
,tkt.VisitType
,ttr.Result
,ttr.TaskCounter
FROM tblTaskResults ttr
LEFT JOIN tlkpKeyTasks tkt ON tkt.TaskCounter = ttr.TaskCounter
AND tkt.TaskCounter IN (
'001410'
,'001463'
,'001431'
,'001411'
,'001464'
,'001432'
)
) AS tktResults
ON tc2.VisitType = tktResults.VisitType
AND tktResults.ChildCounter = tc2.ChildCounter
WHERE tc2.VisitType in (1, 2, 3, 4)
AND tc2.ConsDate > '20130127' AND tc2.ConsDate < '20130228'
GROUP BY CINT(MID(TC2.CHILDCOUNTER, 7, LEN(TC2.CHILDCOUNTER)))
,TC2.VISITTYPE
,TC.CENTRECODE
,TC2.CENTRECODE
,TC2.COUNCILCODE
,TC2.CONSDATE
,TC.FEEDING3MONTHS
,TC.FEEDING6MONTHS
,TC.FEEDING12MONTHS
,TC2.WEIGHT
,TC2.HEADCIRC
ORDER BY CINT(MID(TC2.CHILDCOUNTER, 7, LEN(TC2.CHILDCOUNTER)) ), TC2.VISITTYPE