日期:2014-05-17 浏览次数:20618 次
create table #tb(field1 varchar(10),field2 varchar(10),field3 varchar(10))
insert into #tb
select '張三','5','A'
union all select '張三',null,'B'
union all select '張三',56,'C'
union all select '張三',4,'A'
union all select '李四',8,'T'
union all select '李四',5,'E'
union all select '李四',2,null
union all select '李四',3,'E'
union all select '李四',4,'Y'
union all select '李四',7,'Y'
union all select '王五',8,'T'
union all select '王五',8,'H'
union all select '王五',4,'G'
union all select '趙六',2,'J'
union all select '趙六',34,'E'
union all select '趙六',5,'Y'
union all select '趙六',6,'U'
union all select '趙六',4,'H'
union all select '趙六',8,'B'
union all select '趙六',7,'F'
union all select '趙六',8,'R'
select distinct field1
from #tb
where field1 not in(select field1 from #tb where isnull(field1,'')='' or isnull(field2,'')='')
drop table #tb
/*
李四
王五
趙六
*/