declare @i int select distinct zcj into #t from t order by zcj--按zcj排序 select @i=floor(count(*)*0.9) from #t--需要删除的90%的数量 set rowcount @i--只删除90%的zcj delete from #t--删除 select * from t where zcj in (select zcj from #t)--剩下10% drop table #t set rowcount 0
update table1 set remart=1 where zcj=(select top 10 percent zcj from table1 order by zcj desc)
select distinct zcj into #t from t order by zcj--按zcj排序
select @i=floor(count(*)*0.9) from #t--需要删除的90%的数量
set rowcount @i--只删除90%的zcj
delete from #t--删除
select * from t where zcj in (select zcj from #t)--剩下10%
drop table #t
set rowcount 0