oracle数据库删除重复行记录并保留一行的SQL语句怎么写?
2个回答
展开全部
delete from tab where ROWID IN (
SELECT ROWID FROM (SELECT RANK()OVER(PARTITION BY 重复字段 ORDER BY ROWID) t
FROM tab WHERE 重复字段 IN (select name1 from tab group by 重复字段 HAVING COUNT(重复字段)>1)) WHERE t>1);
SELECT ROWID FROM (SELECT RANK()OVER(PARTITION BY 重复字段 ORDER BY ROWID) t
FROM tab WHERE 重复字段 IN (select name1 from tab group by 重复字段 HAVING COUNT(重复字段)>1)) WHERE t>1);
更多追问追答
追问
查询数据库表中第15行的记录SQL语句怎么写?
追答
delete from tab where rowid=(
select ii from (select ROWNUM nn,ROWID ii from tab WHERE ROWNUM<=15) WHERE nn=15);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询