【问题标题】:Getting ORA-00928: missing SELECT keyword error获取 ORA-00928: 缺少 SELECT 关键字错误
【发布时间】:2018-01-20 11:21:23
【问题描述】:

我遇到了一个错误

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

【问题讨论】:

  • 您不能从 cte 中删除行,因此它们必须后跟一个 select。也许你想把它包装在一个子查询和你的 RN > 1 条件的 where 子句中

标签: sql oracle


【解决方案1】:

这不是在 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
                  );

【讨论】:

    猜你喜欢
    • 2018-07-23
    • 2018-09-17
    • 2018-05-13
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 2019-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多