Senin, 14 Mei 2012

RE: [MS_AccessPros] Can these queries be put into one query?

 

Connie-

Please explain what you mean by "combine them." I see no IIf statements in your
SQL.

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

------------------------

From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of mrsgoudge
Sent: Monday, May 14, 2012 10:41 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Can these queries be put into one query?

 
Hi all!

I have two queries which in the next step are joined in a union query with other
similar queries. These two are from the same tables and joins but one has "10 As
StatusID" and the other has "8 As StatusID". The only way I can think of to
combine them is to use an Iff statement in the statusID column which I fear will
result in "cannot open more databases" and a decrease in speed. Would it be best
to combine them using the Iff statement or leave them as is or ....? I'd like to
speed up the process and decrease the potential for a "cannot open any more
databases" error.

They are both below.

Thanks!
Connie

SELECT SalesBuyers.ContactID, 10 AS StatusID, Sales.ListID, Sales.SoldDate
FROM (Listings INNER JOIN Sales ON Listings.ListID = Sales.ListID) INNER JOIN
SalesBuyers ON Sales.SalesID = SalesBuyers.SaleID
WHERE (((Sales.SoldDate) Is Not Null) AND ((Sales.BuyerAgencyID)<>1 Or
(Sales.BuyerAgencyID) Is Null));

SELECT SalesBuyers.ContactID, 8 AS StatusID, Sales.ListID
FROM (Listings INNER JOIN Sales ON Listings.ListID = Sales.ListID) INNER JOIN
SalesBuyers ON Sales.SalesID = SalesBuyers.SaleID
WHERE (((Sales.BuyerAgencyID)=1) AND ((Sales.SoldDate) Is Not Null)) OR
(((Sales.SoldDate) Is Not Null) AND ((Listings.ListingAgency)=1));

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar