Solved

Condense two queries to one

Posted on 2014-04-24
1
234 Views
Last Modified: 2014-04-24
I have two query that I would like to condense to one. The second query only pulls value where the IsDate([DayRecorded])=True. Is there a way to write this "where" in the first query so there doesn't have to be two queries?

First query titled qryBookingDayswithYearIII

SELECT Bookings.CustomerID, Format([Bookings.DateRecorded],"mm-dd-yy") AS DayRecorded, [Booking Details Extended].BookNumber, Sum([Booking Details Extended].ExtendedPrice) AS SumOfExtendedPrice
FROM Bookings INNER JOIN [Booking Details Extended] ON Bookings.BookNumber = [Booking Details Extended].BookNumber
GROUP BY Bookings.CustomerID, Format([Bookings.DateRecorded],"mm-dd-yy"), [Booking Details Extended].BookNumber
HAVING (((Format([Bookings.DateRecorded],"mm-dd-yy"))=True));

Open in new window


2nd Query: qryBookingDayswithYearIIIB
SELECT *
FROM qryBookingDayswithYearIII
WHERE IsDate([DayRecorded])=True;

Open in new window

0
Comment
Question by:cansevin
1 Comment
 
LVL 6

Accepted Solution

by:
Dulton earned 500 total points
ID: 40020963
Not sure what you're "Having" clause in query 1 is doing here. I'll eliminate it.

just move the isdate to the where and you should have it.

SELECT Bookings.CustomerID, Format([Bookings.DateRecorded],"mm-dd-yy") AS DayRecorded, [Booking Details Extended].BookNumber, Sum([Booking Details Extended].ExtendedPrice) AS SumOfExtendedPrice
FROM Bookings INNER JOIN [Booking Details Extended] ON Bookings.BookNumber = [Booking Details Extended].BookNumber
WHERE IsDate([Bookings].[DateRecorded])=True
GROUP BY Bookings.CustomerID, Format([Bookings.DateRecorded],"mm-dd-yy"), [Booking Details Extended].BookNumber; 

Open in new window

0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
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.

808 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