Help with query...

Myriad_Rocker

Questioning Reality
Local time
Today, 13:00
Joined
Mar 26, 2004
Messages
166
I'm not using Access for this but I figured this was a good place to help iron out my logic. I can do the SQL from there....

I have attached an example of the data that I'm getting from my current query. It's in Excel. What I want to do, is find out if ANYONE (noted by their ID number) is missing a spouse or a child in their plan. As you can see, everyone has at least one of these. So, my output would be numbers 4 and 5 because they are missing one.

How would the logic work on this?
 
SELECT ID
FROM tblData
GROUP BY ID
HAVING Sum(IIF(Enrolled="Spouse",100,1))<101;


The logic behind the query: If Spouse=100 and a Child=1, then Spouse and one child would be 101, so any ID below 101 would miss either the Spouse or a child.
.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom