When I run the below query, it is giving me an error:
"the SELECT statement includes a reserved word or an argument name that is mispelled, or the punctuation is missing."
Also, I'm fairly sure the IIF statement isn't working right. It needs to say if the Note column = "DEF_PREPARED" then it does that subtraction, otherwise its blank. However, its returning a blank even though I think it should be a subtracted value.
Does anybody see where I goofed?
Code:
SELECT [SFJ Feb Full Perf].EntityID,
[SFJ WF 030115].[SFJ_STATUS First],
[SFJ WF 030115].SFJ_STATUS,
[SFJ WF 030115].Status,
[SFJ WF 030115].PreClose,
[SFJ WF 030115].[SFJ Assistant],
[SFJ WF 030115].SFJ_ASSIGN,
[SFJ Feb Full Perf].[Note ],
[SFJ Feb Full Perf].[Note Date Entered ],
[SFJ WF 030115].[Complaint Filed],
[SFJ WF 030115].[Svc Complete],
[SFJ WF 030115].[AOI Figs Recd],
[SFJ WF 030115].[AOI Figs Reqd],
[SFJ WF 030115].[AOI Prepd],
[SFJ WF 030115].TRIAL_REV_YES,
[SFJ WF 030115].TRIAL_REV_NO,
[SFJ WF 030115].[FC Stage],
[SFJ WF 030115].[Svc Complete]-[SFJ WF 030115].[Complaint Filed] AS [Comp Filed to Svc Comp CT],
[SFJ WF 030115].[AOI Figs Reqd]-[SFJ WF 030115].[Svc Complete] AS [Svc Comp to JFigs Request CT],
[SFJ WF 030115].[AOI Prepd]-[SFJ WF 030115].[AOI Figs Reqd] AS [JFigs Request to AOI Prep CT],
[SFJ WF 030115].[TRIAL_REV_YES]-[SFJ WF 030115].[Svc Complete] AS [Svc Comp to NCIAI "Yes" CT],
[SFJ WF 030115].[TRIAL_REV_NO]-[SFJ WF 030115].[Svc Complete] AS [Svc Comp to NCIAI "No" CT],
IIF([SFJ Feb Full Perf].[Note ] = 'DEF_PREPARED',[SFJ Feb Full Perf].[Note Date Entered ]-[SFJ WF 030115].[Svc Complete],'') as [Svc Comp to Def Prep CT]
[SFJ WF 030115].[SFJ_STATUS First]-[SFJ WF 030115].[SFJ_ASSIGN] AS [SFJ Assign to SFJ Status first CT],
DATE()-[SFJ WF 030115].[SFJ_STATUS] AS [SFJ Status Aging]
FROM [SFJ Feb Full Perf] INNER JOIN [SFJ WF 030115] ON [SFJ Feb Full Perf].EntityID = [SFJ WF 030115].File;