Avatar of cansevin
cansevin
 asked on

Where part of the query

I am trying to build a query and my "ON" part isn't working properly.

I only want this query for the values that have the identical FirstDay and DayRecorded. If those values are not the same, I don't want to include the data in the query. It keeps giving all the data even if the values are not the same. Thanks for any help you can provide!

SELECT qryBookingDayswithYear.CustomerID, qryBookingDayswithYear.FirstDay, qryBookingDayswithYearIII.DayRecorded, Sum(qryBookingDayswithYearIII.ExtendedPrice) AS SumOfExtendedPrice
FROM qryBookingDayswithYear INNER JOIN qryBookingDayswithYearIII ON qryBookingDayswithYear.CustomerID = qryBookingDayswithYearIII.CustomerID
GROUP BY qryBookingDayswithYear.CustomerID, qryBookingDayswithYear.FirstDay, qryBookingDayswithYearIII.DayRecorded;
Microsoft Access

Avatar of undefined
Last Comment
Gustav Brock

8/22/2022 - Mon
als315

I see no join on these dates in your query. Have you tried to join them?
Guy Hengel [angelIII / a3]

you want to add the 2 fields in the join condition indeed:
SELECT qryBookingDayswithYear.CustomerID, qryBookingDayswithYear.FirstDay, qryBookingDayswithYearIII.DayRecorded, Sum(qryBookingDayswithYearIII.ExtendedPrice) AS SumOfExtendedPrice
FROM qryBookingDayswithYear INNER JOIN qryBookingDayswithYearIII ON ( qryBookingDayswithYear.CustomerID = qryBookingDayswithYearIII.CustomerID
AND qryBookingDayswithYear.FirstDay = qryBookingDayswithYearIII.DayRecorded ) GROUP BY qryBookingDayswithYear.CustomerID, qryBookingDayswithYear.FirstDay, qryBookingDayswithYearIII.DayRecorded; 

Open in new window

Guy Hengel [angelIII / a3]

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Gustav Brock

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.