Hello All,
I am working on a query that is using a UNION to join two other queries. I have another successful UNION based query in this db which returns no errors and looks almost identical to this query except for the SELECTed fields. I am receiving the following error when I run it through a checker online:
I am working on a query that is using a UNION to join two other queries. I have another successful UNION based query in this db which returns no errors and looks almost identical to this query except for the SELECTed fields. I am receiving the following error when I run it through a checker online:
Despite my best efforts I have not been able to figure out what I'm doing wrong here - any help would be much appreciated.You have an error in your SQL syntax; it seems the error is around: '[All Recorded by Job].ProjectID, [All Recorded by Job].[Project Name], [All ' at line 2
Code:
SELECT
[All Recorded by Job].ProjectID,
[All Recorded by Job].[Project Name],
[All Recorded by Job].Client,
[All Estimates by Job].[SumofBid Hours],
[All Recorded by Job].[SumofRecorded Hours],
NZ ([All Estimates by Job].[SumofBid Hours])-NZ ([All Recorded by Job].[SumofRecorded Hours]) AS [TotalHours Difference],
[All Estimates by Job].[SumOfBid Cost] AS [TotalEstimated Cost],
[All Recorded by Job].[JTD Cost] AS [TotalCost to Date],
NZ ([All Estimates by Job].[SumOfBid Cost])-NZ ([All Recorded by Job].[JTD Cost]) AS [TotalCost Difference],
[All Recorded by Job].[JTD Billed],
NZ ([All Recorded by Job].[JTD Billed])-NZ ([All Recorded by Job].[JTD Cost]) AS [Over/Under Billed],
[All Recorded by Job].[Project Status],
[All Recorded by Job].[PM]
FROM
[All Recorded by Job] LEFT JOIN [All Estimates by Job] ON ([All Recorded by Job].ProjectID=[All Estimates by Job].ProjectID)
UNION SELECT
[All Estimates by Job].ProjectID,
[All Estimates by Job].[Project Name],
[All Estimates by Job].Client,
[All Estimates by Job].[SumofBid Hours],
[All Recorded by Job].[SumofRecorded Hours],
NZ ([All Estimates by Job].[SumofBid Hours])-NZ ([All Recorded by Job].[SumofRecorded Hours]) AS [TotalHours Difference],
[All Estimates by Job].[SumOfBid Cost] AS [TotalEstimated Cost],
[All Recorded by Job].[JTD Cost] AS [TotalCost to Date],
NZ ([All Estimates by Job].[SumOfBid Cost])-NZ ([All Recorded by Job].[JTD Cost]) AS [TotalCost Difference],
[All Recorded by Job].[JTD Billed],
NZ ([All Recorded by Job].[JTD Billed])-NZ ([All Recorded by Job].[JTD Cost]) AS [Over/Under Billed],
[All Estimates by Job].[Project Status],
[All Estimates by Job].[PM]
FROM
[All Recorded by Job] LEFT JOIN [All Estimates by Job] ON ([All Recorded by Job].ProjectID=[All Estimates by Job].ProjectID)
WHERE [All Estimates by Job].ProjectID IS NOT Null