我知道可以选择第n行。
例如
select from table limit 1 offset 3;
是否可以删除第n行?
答案 0 :(得分:0)
如果您有id
以及order by
和/或partition by
,delete
可以row_number()
使用drop table if exists t;
create table t (id int, val int);
insert into t values (1,9),(2,8),(3,7),(4,6),(5,5);
delete
from t
where id in (
select id
from (
select id, row_number() over (order by val asc) as rn
from t
) s
where s.rn = 3);
select * from t;
:
+----+-----+
| id | val |
+----+-----+
| 1 | 9 |
| 2 | 8 |
| 4 | 6 |
| 5 | 5 |
+----+-----+
rextester演示:http://rextester.com/XJHB50704
返回:
at