获取ORA-00928:缺少SELECT关键字错误

时间:2017-08-11 21:02:03

标签: sql oracle

我收到错误

  

ORA-00928:缺少SELECT关键字

运行此查询时

WITH Dups AS
(
    SELECT 
        ID, AMOUNT, BATCH_ID, PROCESS_DATE, ITEM_NUMBER, ERROR_TYPE, INSERTED_DATE, 
        ROW_NUMBER() OVER(PARTITION BY ID, ERROR_TYPE ORDER BY ID) AS rn
    FROM 
        ERROR_TABLE
    WHERE
        inserted_date >= TRIM(TO_DATE('01-AUG-17', 'DD-MON-YY')) 
        AND inserted_date <= TRIM(TO_DATE('11-AUG-17', 'DD-MON-YY'))
)
DELETE FROM Dups 
WHERE rn > 1

1 个答案:

答案 0 :(得分:3)

这不是如何删除Oracle中的重复项。灵感,但不适用于该数据库。像这样:

delete error_table et
    where et.inserted_date >= date '2017-08-01' and
          et.inserted_date <= date '2017-08-11' and
          rowid > (select min(et2.rowid)
                   from error_table et2
                   where et2.inserted_date >= date '2017-08-01' and
                         et2.inserted_date <= date '2017-08-11' and
                         et2.id = et.id and
                         et2.error_type = et.error_type
                  );