I have two tables, person and caserl. Person contains person IDs, and caserl has person IDs and end date. I need to select a row from person where all of the end dates on caserl for that person ID are < '9999-12-31'.
QUESTION POSED ON: 26 JUL 2005
QUESTION ANSWERED BY: Rudy Limeback
select Person.personid
from Person
inner
join caserl
on Person.personid = caserl.personid
group
by Person.personid
having count(*)
= sum(case when caserl.enddate < '9999-12-31'
then 1 else 0 end)
|
 |
|