declare @i smallint
declare @j smallint
set @j=1--字段j用于控制循环
select @i=count(distinct num) from spring --字段i用于存放客户的总人数
while @j<=@i
begin
delete from spring where timer in(select distinct timer from spring where num in(select top 1 num from spring group by num having count(num)>1)and timer!=(select max(timer) from spring where num in(select top 1 num from spring group by num having count(num)>1)))
set @j=@j+1
end