日期:2014-05-17 浏览次数:20545 次
create table #t
(
A int,
B int,
C int
)
insert into #t
select 1,1,1 union all
select 1,2,0 union all
select 1,3,1 union all
select 1,4,0
select * from #t
union all
select * from #t where C = 0
order by B,C
INSERT INTO #t SELECT * FROM #t where C=0
SELECT COUNT(*) as co,A,B,C into #t2 FROM #t GROUP BY A,B,C ORDER BY COUNT(*)
SELECT a,b,c into #t3 FROM #t2 WHERE co=(SELECT MIN(co) from #t2)
DELETE a FROM #t a INNER JOIN #t3 b ON a.A=b.A and a.B=b.B and a.c=b.c