i have table this:
i need query return projectid's have state=21. i.e want projectid 2 & 5.
i not want records projectid 1, 3, 4 & 6, because in case, state equal other numbers
reasoning goes
- in subselect, select projectid's have state = 21
- in outer select, retain projectid's have state = 21 using
having
clause
sql statement
select projectid table t1 inner join ( select projectid table state = 21 ) t2 on t2.projectid = t1.projectid group projectid having count(*) = 1
Comments
Post a Comment