Unmatched query...sort of

D

Darrell Childress

I have a table with 4 fields:
SONumber, InvDate, InvAmount, Complete (Yes/No field)

The table will have multiple records for many SONumber's. I need to
write a query that will find all SONumber's that do NOT have an entry
where the Complete field = Yes.
In other words, we do a lot of partial shipments and I need to find
orders that have shipments, but we haven't made the final shipment yet.
Any suggestions? Thanks,
Darrell
 
G

Guest

Your query should be relatively simple, just add the criteria "No" to the
Complete field in your Select query.
 
J

John Spencer

First, build a query that returns all records where Complete is true(yes)
Then use that in an unmatched query along with you original table.

SQL would look something like

SELECT Distinct SONumber
FROM YourTable LEFT JOIN
(SELECT SONumber
FROM YourTable
WHERE Complete = TRUE) as Finished
ON YourTable.SONumber = Finished.SONumber
WHERE Finished.SONumber is Null

Alternate (may be too slow with large data sets)
SELECT Distinct SONumber
FROM YourTable
WHERE SONumber Not IN
(SELECT Temp.SONumber
FROM YourTable as Temp
WHERE Temp.Complete = TRUE)
 
D

Darrell Childress

I actually had thought of the same solution and was going to post
something similar. Thanks for the response!
Darrell
 
S

Smartin

Nicholas said:
Your query should be relatively simple, just add the criteria "No" to the
Complete field in your Select query.

Unfortunately that doesn't work. It will select an SONumber with a "No"
anywhere, even if the same SONumber has a "Yes" somewhere.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top