如何将Max()KEEP(DENSE_RANK LAST ORDER BY)从Oracle转换为MariaDB或MySQL

时间:2019-05-30 06:09:30

标签: mysql oracle mariadb

我将Oracle迁移到MariaDB。遇到了将Oracle脚本转换为MariaDB脚本的问题,该脚本可以转换为MariaDB吗?

这是一台运行MariaDB 10.3.13的新服务器。我试过在线转换(sqlLines),然后将代码粘贴到HeidiQSQL执行,总是出错。

SELECT o3.id,
    o3.FINISH_DATE,
    o3.START_DATE,
    o3.STEP_OWNER,
    o3.INITIAL_STATUS,
    o3.LAST_STATUS,
    o3.STEP_NAME,
    o3.STAGE_NAME,
    o3.REF_ID,
    o3.REF_STATUS,
    o3.ACTION_BY,
    o3.ELAPSED_TIME,
    DECODE (o3.STEP_NAME, '006' , 'Y' , 'N') AS IS_STP
  FROM os_historyrecord o3
  WHERE o3.id IN
    (SELECT MAX(prev.previous_id) KEEP (DENSE_RANK LAST
    ORDER BY o2.finish_date)
    FROM
      (SELECT id, stage_name, ref_id, finish_date FROM os_currentrecord
      UNION ALL
      SELECT id, stage_name, ref_id, finish_date FROM os_historyrecord
      ) o2,
      (SELECT op.id,
        op.previous_id,
        op.step_index
      FROM os_historyrecord_prev op
      WHERE op.previous_id IN
        (SELECT o.id
        FROM os_historyrecord o,
          LOSA_APP app
        WHERE o.REF_ID       = app.APP_NO
        AND o.stage_name     = '003'
        AND app.product_type = 'CL'
        GROUP BY o.id
        )
      AND op.step_index = 0
      ) prev
    WHERE PREV.id       = O2.id
    AND (O2.STAGE_NAME IN '004'
    OR O2.STAGE_NAME    = '005'
    OR O2.Stage_Name    = '006')
    GROUP BY O2.Ref_Id
    );

我希望MariaDB可以和Oracle一样。

HeidiSQL中的错误提示。 Execute error from MariaDB

0 个答案:

没有答案