НЕ ПЕТЛЯТЬ!
Я предпочитаю помечать th строки статусом, но это будет делать, как вы хотите, и удалять их ...
попробуйте это (сервер sql)
накрытый стол
create table tREaltyTrac (city varchar(20),creation datetime)
insert into tREaltyTrac values ('Acampo' ,getdate()) --1
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Acton' ,getdate()) --1
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Adelanto' ,getdate()) --20
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Agua Dulce' ,getdate()) --1
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Aguanga' ,getdate()) --1
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Akron' ,getdate()) --19
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albany' ,getdate()) --12
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albion' ,getdate()) --3
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albion' ,getdate()) --3
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Albion' ,getdate()) --3
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alexandria' ,getdate()) --14
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Algonac' ,getdate()) --1
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alhambra' ,getdate()) --5
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alhambra' ,getdate()) --5
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alhambra' ,getdate()) --5
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alhambra' ,getdate()) --5
waitfor delay '00:00:01'
insert into tREaltyTrac values ('Alhambra' ,getdate()) --5
отображение табличных значений
select city,count(*) from tREaltyTrac group by city
select * from tREaltyTrac
удалить ненужные строки
delete from tREaltyTrac
from tREaltyTrac
inner join (select
city,creation, row_number() over(partition by city order by city) AS RankValue
from tREaltyTrac
) dt on tREaltyTrac.city=dt.city AND tREaltyTrac.creation=dt.creation
where dt. RankValue>10
показать строки, которые вы оставили
select * from tREaltyTrac
select city,count(*) from tREaltyTrac group by city