日期:2014-05-17 浏览次数:20481 次
create table #tb(MemberID int ,P1 varchar(10), P2 varchar(10), P3 varchar(10))
insert into #tb
select 1,'1A','2B','3A'
union all select 2,'1B','2D','3C'
union all select 3,'1A','2E','3B'
union all select 4,'1C','2A','3D'
union all select 5,'1D','2C','3E'
union all select 6,'1D','2B','3C'
select MemberID,P1, 1 as groupID
from #tb a
where exists (select 1 from