cansevin
asked on
Query not working
I am trying to build a query that is both a left and right join. It is saying "The SELECT statement includes a reserved word or argument name that is misspelled or missing, or the punctuation is incorrect."
My query is:
SELECT A.MessagesRecorded, A.TotalNewClients, A.BookedTrue, A.TalkedTo, A.PercentBooked, A.FiveMinCallBack, A.PercentinFive, A.DateField, B.SumOfSumOfExtendedPrice as B.SumOfSumOfExtendedPrice
FROM qryStatsIndividual as A
LEFT JOIN qryBookingDayswithYearII B
ON A.DateField = B.DateField
UNION ALL
SELECT NULL AS MessagesRecorded, NULL AS TotalNewClients, NULL AS BookedTrue, NULL AS TalkedTo, NULL AS PercentBooked, NULL AS FiveMinCallBack, NULL AS PercentinFive, B.DateField, B.SumOfSumOfExtendedPrice
FROM qryBookingDayswithYearII as B
LEFT JOIN qryStatsIndividual A
ON B.DateField = A.DateField
WHERE A.DateField IS NULL
My query is:
SELECT A.MessagesRecorded, A.TotalNewClients, A.BookedTrue, A.TalkedTo, A.PercentBooked, A.FiveMinCallBack, A.PercentinFive, A.DateField, B.SumOfSumOfExtendedPrice as B.SumOfSumOfExtendedPrice
FROM qryStatsIndividual as A
LEFT JOIN qryBookingDayswithYearII B
ON A.DateField = B.DateField
UNION ALL
SELECT NULL AS MessagesRecorded, NULL AS TotalNewClients, NULL AS BookedTrue, NULL AS TalkedTo, NULL AS PercentBooked, NULL AS FiveMinCallBack, NULL AS PercentinFive, B.DateField, B.SumOfSumOfExtendedPrice
FROM qryBookingDayswithYearII as B
LEFT JOIN qryStatsIndividual A
ON B.DateField = A.DateField
WHERE A.DateField IS NULL
ASKER
Just fixed that, thanks! Still giving me the same error:
SELECT A.MessagesRecorded, A.TotalNewClients, A.BookedTrue, A.TalkedTo, A.PercentBooked, A.FiveMinCallBack, A.PercentinFive, A.DateField, B.SumOfSumOfExtendedPrice as B.SumOfSumOfExtendedPrice
FROM qryStatsIndividual as A
LEFT JOIN qryBookingDayswithYearII AS B
ON A.DateField = B.DateField
UNION ALL
SELECT NULL AS MessagesRecorded, NULL AS TotalNewClients, NULL AS BookedTrue, NULL AS TalkedTo, NULL AS PercentBooked, NULL AS FiveMinCallBack, NULL AS PercentinFive, B.DateField, B.SumOfSumOfExtendedPrice
FROM qryBookingDayswithYearII as B
LEFT JOIN qryStatsIndividual A
ON B.DateField = A.DateField
WHERE A.DateField IS NULL
SELECT A.MessagesRecorded, A.TotalNewClients, A.BookedTrue, A.TalkedTo, A.PercentBooked, A.FiveMinCallBack, A.PercentinFive, A.DateField, B.SumOfSumOfExtendedPrice as B.SumOfSumOfExtendedPrice
FROM qryStatsIndividual as A
LEFT JOIN qryBookingDayswithYearII AS B
ON A.DateField = B.DateField
UNION ALL
SELECT NULL AS MessagesRecorded, NULL AS TotalNewClients, NULL AS BookedTrue, NULL AS TalkedTo, NULL AS PercentBooked, NULL AS FiveMinCallBack, NULL AS PercentinFive, B.DateField, B.SumOfSumOfExtendedPrice
FROM qryBookingDayswithYearII as B
LEFT JOIN qryStatsIndividual A
ON B.DateField = A.DateField
WHERE A.DateField IS NULL
BTW, same thing here:
LEFT JOIN qryStatsIndividual A
Should be:
LEFT JOIN qryStatsIndividual As A
Jim.
LEFT JOIN qryStatsIndividual A
Should be:
LEFT JOIN qryStatsIndividual As A
Jim.
Also, just to be clear, each statement before and after the UNION ALL needs to stand on it's own.
Copy/Paste each statement into the query desinger when in SQL view and see if they fly.
Jim.
Copy/Paste each statement into the query desinger when in SQL view and see if they fly.
Jim.
ASKER
Unfortunately, it's still doing it. What do you mean by Copy/Past each statement? Where would the error be? I miss spell a field name?
To show the idea using simple tables:
a(a, ...)
a
1
2
4
b(b, ...)
1
2
5
a(a, ...)
a
1
2
4
b(b, ...)
1
2
5
Select a.a, b.b From a Left Join b On a.a=b.b
Union All
Select a.a, b.b From b Left Join a On b.a=a.b;
a b
1 1
2 2
4
5
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
try this
SELECT A.MessagesRecorded, A.TotalNewClients, A.BookedTrue, A.TalkedTo, A.PercentBooked, A.FiveMinCallBack, A.PercentinFive, A.DateField, B.SumOfSumOfExtendedPrice
FROM qryStatsIndividual as A
LEFT JOIN qryBookingDayswithYearII AS B
ON A.DateField = B.DateField
UNION ALL
SELECT NULL AS MessagesRecorded, NULL AS TotalNewClients, NULL AS BookedTrue, NULL AS TalkedTo, NULL AS PercentBooked, NULL AS FiveMinCallBack, NULL AS PercentinFive, B.DateField, B.SumOfSumOfExtendedPrice
FROM qryBookingDayswithYearII as B
LEFT JOIN qryStatsIndividual A
ON B.DateField = A.DateField
WHERE A.DateField IS NULL
SELECT A.MessagesRecorded, A.TotalNewClients, A.BookedTrue, A.TalkedTo, A.PercentBooked, A.FiveMinCallBack, A.PercentinFive, A.DateField, B.SumOfSumOfExtendedPrice
FROM qryStatsIndividual as A
LEFT JOIN qryBookingDayswithYearII AS B
ON A.DateField = B.DateField
UNION ALL
SELECT NULL AS MessagesRecorded, NULL AS TotalNewClients, NULL AS BookedTrue, NULL AS TalkedTo, NULL AS PercentBooked, NULL AS FiveMinCallBack, NULL AS PercentinFive, B.DateField, B.SumOfSumOfExtendedPrice
FROM qryBookingDayswithYearII as B
LEFT JOIN qryStatsIndividual A
ON B.DateField = A.DateField
WHERE A.DateField IS NULL
ASKER
Thanks for your help Jim! It worked. Now it is giving me some "overflow" problem. I'll open another question for that. Thanks again!
LEFT JOIN qryBookingDayswithYearII B
should be
LEFT JOIN qryBookingDayswithYearII AS B
Jim.