I have got SQL query running successfully in Oracle, the code is-
Select Sam.SAM_ID, sum( case when Aud.AUDIT_COMPLETION between (next_day(trunc(sysdate, 'iw'), 'Friday') -  14) and 
(next_day(trunc(sysdate, 'iw'), 'Friday') - 7) then 1 else 0 end ) as "Major Defects - 1 week",
 sum( case when Aud.AUDIT_COMPLETION between (next_day(trunc(sysdate, 'iw'), 'Friday') -  28) and (next_day(trunc(sysdate, 'iw'), 'Friday') - 7) then 1 else 0 end ) as "Major Defect - 4 week", count(Aud.AUDIT_COMPLETION)
From CMS.CMS_SAM_ALL_DATA Sam left join CMS.WATSON_AUDIT_INSPECTION_DT1_VW Aud ON Sam.SAM_ID = Aud.SAM_ID
Where Aud.DEFECT_SEVERITY = 'Major' AND 
Aud.AUD_RESULT = 'Defect' And 
NOT (Aud.AUDIT_OUTCOME = 'SPFR Withdrawn' and 
Aud.AUDIT_OUTCOME = 'Defect/ Observation Cancelled' and 
Aud.AUDIT_OUTCOME = 'Rejected by MIMA' and 
Aud.AUD_RESULT = 'Fixed' and 
Aud.AUDIT_OUTCOME = 'SPFR response accepted') and 
Aud.AUDIT_COMPLETION IS NOT NULL
Group by Sam.SAM_ID; 
Now I tried running the above code in macro(VBA) but not able to run macro successfully, Macro code -
StrSQL = StrSQL & "Select Sam.SAM_ID,"
 StrSQL = StrSQL & "sum(case when Aud.AUDIT_COMPLETION between (next_day(trunc(sysdate, 'iw'), 'Friday') - 14) and (next_day(trunc(sysdate, 'iw'), 'Friday') - 7) then 1 else 0 end )as ""Major Defects - 1 week"","
    StrSQL = StrSQL & "sum(case when Aud.AUDIT_COMPLETION between (next_day(trunc(sysdate, 'iw'), 'Friday') - 28) and (next_day(trunc(sysdate, 'iw'), 'Friday') - 7) then 1 else 0 end )as ""Major Defect - 4 week"","
    StrSQL = StrSQL & "count(Aud.AUDIT_COMPLETION)as ""Total Open Defects""
    StrSQL = StrSQL & "From CMS.CMS_SAM_ALL_DATA Sam left join CMS.WATSON_AUDIT_INSPECTION_DT1_VW Aud ON Sam.SAM_ID = Aud.SAM_ID"
    StrSQL = StrSQL & "Where Aud.DEFECT_SEVERITY = 'Major' AND Aud.AUD_RESULT = 'Defect' And NOT (Aud.AUDIT_OUTCOME = 'SPFR Withdrawn' and Aud.AUDIT_OUTCOME = 'Defect/ Observation Cancelled' and Aud.AUDIT_OUTCOME = 'Rejected by MIMA' and Aud.AUD_RESULT = 'Fixed' and Aud.AUDIT_OUTCOME = 'SPFR response accepted') and Aud.AUDIT_COMPLETION IS NOT NULL, Aud.AUDIT_COMPLETION IS NOT NULL, "
    StrSQL = StrSQL & "Group by Sam.SAM_ID;"
When I run above code I get an error as -
FROM Keyword not found where expected
