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.
Author |
Topic |
srujanavinnakota
Starting Member
34 Posts |
Posted - 2011-01-27 : 14:47:02
|
Want help with the Select query. I want to select the AYID's Where all of the AIDID Flags are TRUE. Below is the Sample data AidID AYID Flag7935427 7385823 FALSE8190980 7385823 TRUE7935422 7385823 TRUEI tried below query Select AYID From test where Flag<>'False'I want the query to return NULL Because all the values of the Flag should be TRUE for that AYID |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-01-27 : 15:15:16
|
SELECT t1.*FROM yourTable t1INNER JOIN( select AYID,Flag,[Rank] = dense_rank() over(partition by ayid order by flag) from yourTable) t2ON t1.ayid = t2.ayidWHERE t2.[rank] = 1and t2.flag = 'TRUE'JimEveryday I learn something that somebody else already knew |
 |
|
srujanavinnakota
Starting Member
34 Posts |
Posted - 2011-01-27 : 16:44:33
|
Thanks So much. It worked... |
 |
|
|
|
|