Hi All, I am trying to call the following SQL query from a VBA Macro but I get the "ORA-00923: FROM keyword not found where expected" error. Couple times I even got a related ORA error about SQL not being complete. I tried a lot of different things based on internet research on forums but to no avail. Can anyone please help? Thanks!

SQL_String_YTD = "select t.ClientID, SUM(t.ABC), SUM(t.DEF), SUM(t.ClientCount) " _
& "FROM (" _
& "SELECT ffclient_id as 'ClientID', sum(FIELD1) as 'ABC'," _
& "sum(decode(Greek, 'ALPHA', greek_is_alpha, 'BETA', greek_is_beta, 0 )) as 'DEF'," _
& "count(*) as 'ClientCount'" _
& "FROM Table123" _
& "WHERE timestamp is NOT null AND" _
& "status<>'FAILED' AND" _
& "last_update_time BETWEEN trunc(SYSDATE, 'YEAR') AND to_date(sysdate, 'DD.MM.YY HH24:MI')" _
& "group by ffclient_id" _
& "Union ALL" _
& "SELECT ffclient_id as 'ClientID'," _
& "sum(FIELD1) as 'ABC'," _
& "sum(decode(Greek, 'ALPHA', greek_is_alpha, 'BETA', greek_is_beta, 0 )) as 'DEF'," _
& "count(*) as 'ClientCount'" _
& "FROM Table123_archive" _
& "WHERE timestamp is NOT null AND" _
& "status<>'FAILED' AND" _
& "last_update_time BETWEEN trunc(SYSDATE, 'YEAR') AND to_date(sysdate, 'DD.MM.YY HH24:MI')" _
& "group by ffclient_id" _
& ") t" _
& "group by t.ClientID" _