ORA:00928 SELECT关键字丢失

时间:2019-06-28 12:23:30

标签: oracle

删除重复行的代码

获取选择关键字缺少错误。请帮我解决。

  With studentCTE As (
    Select ROW_NUMBER() Over(Partition BY RNO ORDER By NAME) as RowNumber 
      from student) 

   Delete from studentCTE 
    where RowNumber > 1; 

   select * from studentCTE;

1 个答案:

答案 0 :(得分:0)

如果要从表中删除,则需要以单词DELETE开头。您可以使用查询选择要删除的行,但是查询的每个部分(包括WITH子句)都必须在DELETE之后合并在一起。

delete from student where rowid in (
  with cte as (
    select ROW_NUMBER() Over(Partition BY RNO ORDER By NAME) as RowNumber,
      rowid as rid
    from student
  )
  select rid from cte
  where rownumber > 1
);