declare @mycount int, case when (select count(aa.cl) as mycount>1 from aa group by aa.cl) then (delete from aa top @mycount-1 order by aa.c2 group by aa.c1) else when (select count(aa.cl) as mycount>1 from aa group by aa.c2)) then (delete from aa top @mycount-1 order by aa.c1 group by aa.c2)
有点问题应该是 declare @mycount int, case when (select count(aa.cl) as mycount>1 from aa group by aa.cl) then (delete from aa top @mycount-1 order by aa.c2 DESC group by aa.c1) else when (select count(aa.cl) as mycount>1 from aa group by aa.c2)) then (delete from aa top @mycount-1 order by DESC aa.c1 group by aa.c2) END CASE
delete from aa where aa.c2<>(select c2 from (select distinct(c1),c2 from aa)) or(aa.c1<>(select c1 from (select distinct(c2),c1 from aa)))
select * from aa where aa.c1 in(select distinct aa.c1 from aa)
delete from aa where aa.c2<>(select c2 from (select distinct(c1),c2 from (select*from aa order by c2)) or(aa.c1<>(select c1 from (select distinct(c2),c1 from (select*from aa order by c1))))
case when (select count(aa.cl) as mycount>1 from aa group by aa.cl) then (delete from aa top @mycount-1 order by aa.c2 group by aa.c1) else when (select count(aa.cl) as mycount>1 from aa group by aa.c2)) then (delete from aa top @mycount-1 order by aa.c1 group by aa.c2)
declare @mycount int,
case when (select count(aa.cl) as mycount>1 from aa group by aa.cl) then (delete from aa top @mycount-1 order by aa.c2 DESC group by aa.c1) else when (select count(aa.cl) as mycount>1 from aa group by aa.c2)) then (delete from aa top @mycount-1 order by DESC aa.c1 group by aa.c2) END CASE
where aa.c2<>(select c2 from (select distinct(c1),c2 from aa))
or(aa.c1<>(select c1 from (select distinct(c2),c1 from aa)))
where aa.c2<>(select c2 from (select distinct(c1),c2 from (select*from aa order by c2))
or(aa.c1<>(select c1 from (select distinct(c2),c1 from (select*from aa order by c1))))