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 |
gfaryd
Starting Member
27 Posts |
Posted - 2010-05-20 : 05:02:21
|
I have following table structure i m using sql 2000create table mytab(pid varchar(10),a_check char(1),b_check char(1)detail varchar(30))it has following datainsert into mytab values ('abc1','A','A','good')insert into mytab values ('abc1',null,null,'')insert into mytab values ('abc2','A','B','good')insert into mytab values ('abc2',null,null,'')insert into mytab values ('abc3','A','A','good')insert into mytab values ('abc3','A','B','Fair')what i want in result those PID where value of both a_check and b_check is not null in all rows like in above data set i want only pid values to be returnisabc3 i dont want abc1 and abc2 in result as one row of them contains nullRegardsonly those values return where |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-05-20 : 05:05:57
|
[code]select *from mytab twhere not exists ( select * from mytab x where x.pid = t.pid and ( x.a_check is null or x.b_check is null ) )[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-05-20 : 05:39:56
|
If SQL 2005 +Try thisSelect * from (Select *,row_number() over( partition by pid order by pid) as rank_nofrom mytab where a_check is not null and b_check is not null) awhere rank_no>1Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
|
|
|
|