Solved

Where part of the query

Posted on 2014-01-04
4
389 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

726 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