Solved

Where part of the query

Posted on 2014-01-04
4
390 Views
Last Modified: 2014-01-04
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;
0
Comment
Question by:cansevin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Expert Comment

by:als315
ID: 39756432
I see no join on these dates in your query. Have you tried to join them?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39756441
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

0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39756442
0
 
LVL 50

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 39756446
Try with:

SELECT qryBookingDayswithYear.CustomerID, qryBookingDayswithYear.FirstDay, qryBookingDayswithYearIII.DayRecorded, Sum(qryBookingDayswithYearIII.ExtendedPrice) AS SumOfExtendedPrice

FROM qryBookingDayswithYear INNER JOIN qryBookingDayswithYearIII ON qryBookingDayswithYear.CustomerID = qryBookingDayswithYearIII.CustomerID

HAVING qryBookingDayswithYear.FirstDay = qryBookingDayswithYearIII.DayRecorded

GROUP BY qryBookingDayswithYear.CustomerID, qryBookingDayswithYear.FirstDay, qryBookingDayswithYearIII.DayRecorded;

or replace HAVING  with WHERE.

/gustav
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question