これを試して:
with a as
(
select ROW_NUMBER() over(order by name) as ordinal, * from test
)
delete from a where a.ordinal > 10;
関連:http ://www.ienablemuch.com/2012/03/possible-in-sql-server-deleting-any-row.html
サンプルデータ:
CREATE TABLE [beatles]
([name] varchar(14));
INSERT INTO [beatles]
([name])
VALUES
('john'),
('paul'),
('george'),
('ringo'),
('pete'),
('brian'),
('george martin');
クエリ:
with a as
(
select *, row_number() over(order by name) ordinal
from beatles
)
delete from a
where ordinal > 4;
select * from beatles;
削除前:
NAME
brian
george
george martin
john
paul
pete
ringo
削除後:
NAME
brian
george
george martin
john
ライブテスト:http ://www.sqlfiddle.com/#!3/0adcf/6