Here I go again.
I'm trying to write a SQL query to pull a distinct list of outstanding purchases. This works in MS Access, but when I translate it to SQL (remove dbo_ from the tables, change " to ') it claims the syntax is off.
Specifically it says "Incorrect syntax near the keyword "Purchase".
I'm trying to write a SQL query to pull a distinct list of outstanding purchases. This works in MS Access, but when I translate it to SQL (remove dbo_ from the tables, change " to ') it claims the syntax is off.
Specifically it says "Incorrect syntax near the keyword "Purchase".
Code:
SELECT DISTINCT Purchase.PurchaseNumber, Purchase.PurchaseDate, Purchase.PurchaseAmount, Company.LegalName, GLAccounts.GLAccount_Code, Purchase.Reconciliation_Key, CustomerAccount.CustomerName
FROM
((Purchase INNER JOIN GLAccounts ON Purchase.GLAccount_Key = GLAccounts.GLAccount_Key) INNER JOIN BatchControl ON Purchase.BatchControl_Key = BatchControl.BatchControl_Key)
INNER JOIN (Company INNER JOIN CustomerAccount ON Company.Company_Key = CustomerAccount.Company_Key) ON (BatchControl.Company_Key = Company.Company_Key) AND (GLAccounts.GLAccount_Key = CustomerAccount.GLAccount_Key)
INNER JOIN CompanyUserFields ON Company.Company_Key = CompanyUserFields.Company_Key
WHERE Purchase.Reconciliation_Key Is Null AND CompanyUserFields.Rollup="Aggregated"