Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Select obsolete

Author  Topic 

lane0618
Posting Yak Master

134 Posts

Posted - 2003-02-20 : 13:29:17
I have the following recordset:

dir code status
abc x active
abc c obsolete
abc r obsolete
def f obsolete
def g obsolete
ghj t active
ghj x obsolete

I want to select only the records where the status is obsolete for all of the records with the same dir. I should end up with:

dir
def

Thanks in Advance,
Lane

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-02-20 : 13:56:14
select dir
from table
group by dir
having COUNT(*) = sum(CASE WHEN status = 'obsolete' THEN 1 ELSE 0 END)

- Jeff
Go to Top of Page
   

- Advertisement -