Newbie query

C

Chris

I have a table with 3 columns in it. The first column
contains names, the second column contains description
and the third contains status. I want to build a query
that returns only the users that all have an OK status
against all the descriptions against them. Any help with
this would be greatly appreciated.
 
J

Jeff Boyce

Chris

Create a new query in design mode. Select your users column. Select your
status column. In the criterion under your status column, type "OK".
 
G

Gary Walter

Chris said:
I have a table with 3 columns in it. The first column
contains names, the second column contains description
and the third contains status. I want to build a query
that returns only the users that all have an OK status
against all the descriptions against them. Any help with
this would be greatly appreciated.

Hi Chris,

PMFBI

Just in case this might be a more complicated
problem where a name can appear more
than once (with different descriptions),
and you want to return the names who have
an OK for *all* their descriptions:

SELECT
NameField
FROM YourTable
GROUP BY NameField
HAVING MAX([Status]='OK') = -1;

If you are looking at a group for
one name, if any Status<>'OK',
then the condition will be false (= 0),
so the Max over the group for the condition
will be 0 because at least one record had
a Status <> 'OK'.

If all are 'OK', then condition will be
true (= -1) for all of them, so the Max
of the condition will be -1.

Apologies again for butting in.

Good luck,

Gary Walter
 

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