Senin, 14 Mei 2012

[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