Getting a Syntax Error on nested Select Query

bconner

Registered User.
Local time
Today, 17:02
Joined
Dec 22, 2008
Messages
183
I want to only show records in the first query that don't exist in the second query. However I am getting a syntax error 'missing operator'. I can't figure out where my syntax is off.


Code:
SELECT 
 
[1 Sum with Unique Key].Key1, [1 Sum with Unique Key].Patient_Name, [1 Sum with Unique Key].Invoice_No, [1 Sum with Unique Key].Accession_No, [1 Sum with Unique Key].Procedure_Code, [1 Sum with Unique Key].Date_Of_Service, Sum([1 Sum with Unique Key].Charge_Amount) AS SumOfCharge_Amount
 
FROM [1 Sum with Unique Key]
 
GROUP BY [1 Sum with Unique Key].Key1, [1 Sum with Unique 
Key].Patient_Name, [1 Sum with Unique Key].Invoice_No, [1 Sum with Unique Key].Accession_No, [1 Sum with Unique Key].Procedure_Code, [1 Sum with Unique Key].Date_Of_Service
 
WHERE [1 Sum with Unique Key].Invoice_No
 
NOT IN (SELECT  [GRP-4-2008-2008-CHARGE-CORRECTIONS].INVOICE
FROM  [GRP-4-2008-2008-CHARGE-CORRECTIONS]
GROUP BY [GRP-4-2008-2008-CHARGE-CORRECTIONS].INVOICE);
 
I want to only show records in the first query that don't exist in the second query. However I am getting a syntax error 'missing operator'. I can't figure out where my syntax is off.
there is a double space after the FROM clause in the subquery...


Code:
SELECT 
 
[1 Sum with Unique Key].Key1, [1 Sum with Unique Key].Patient_Name, [1 Sum with Unique Key].Invoice_No, [1 Sum with Unique Key].Accession_No, [1 Sum with Unique Key].Procedure_Code, [1 Sum with Unique Key].Date_Of_Service, Sum([1 Sum with Unique Key].Charge_Amount) AS SumOfCharge_Amount
 
FROM [1 Sum with Unique Key]
 
GROUP BY [1 Sum with Unique Key].Key1, [1 Sum with Unique 
Key].Patient_Name, [1 Sum with Unique Key].Invoice_No, [1 Sum with Unique Key].Accession_No, [1 Sum with Unique Key].Procedure_Code, [1 Sum with Unique Key].Date_Of_Service
 
WHERE [1 Sum with Unique Key].Invoice_No
 
NOT IN (SELECT  [GRP-4-2008-2008-CHARGE-CORRECTIONS].INVOICE
[COLOR="Red"][B]FROM  [GRP-4-2008-2008-CHARGE-CORRECTIONS][/B][/COLOR]
GROUP BY [GRP-4-2008-2008-CHARGE-CORRECTIONS].INVOICE);
 
Thank you!
 

Users who are viewing this thread

Back
Top Bottom