Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Condense two queries to one

Posted on 2014-04-24
1
Medium Priority
?
256 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
[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
1 Comment
 
LVL 6

Accepted Solution

by:
Dulton earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

660 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