ORACLE 11g DB でこのクエリを起動すると、行: 7、列: 6 で「ORA-00907: 右括弧がありません」というエラーが表示されます。
SELECT B.ID_COND AS IDCOND,B.ID_PAYMENT AS IDPAYMENT, B.DT_SCAD AS DATASCAD, B.DT_PAYMENT AS DATAPAYMENT,B.DE_CHANNELPAG AS CHANNELPAYMENT, B.DT_STARTVALID AS DATASTART, B.DT_ENDVALID AS DATAEND,
B.IM_TOTAL AS TOTAL, B.ST_PAYMENT AS STATECOND, B.CO_CIP AS codCIP, B.ID_PEND AS IDPEND, B.TI_PAYMENT AS TIPOPAYMENT,
B.cause_PAYMENT AS causaleCOND, B.IM_PAYMENT AS amountPAYMENT, B.DE_MIDDLEPAYMENT AS MIDDLEPAYMENT, B.DE_NOTEPAYMENT as notePAYMENT,
(select st_PAYMENT from QLT.paymnts P
where P.ID_COND=B.ID_COND
AND ROWNUM <= 1
order by (CASE WHEN P.st_PAYMENT='ES' THEN 1 ELSE 0 END) DESC, TS_INSMNT DESC
) AS STATEPAYMENT
FROM QLT.JLTCOPD B
WHERE B.ID_PEND = '269' AND B.TI_PAYMENT = 'S'
ORDER BY B.DT_SCAD ASC, DT_STARTVALID ASC
この行を削除しようとしています: 'order by (CASE WHEN P.st_PAYMENT='ES' THEN 1 ELSE 0 END) DESC, TS_INSMNT DESC' エラーは表示されず、結果が返されます。
DB2 クエリを ORACLE に変換しようとしています。元の DB2 内部クエリは次のとおりです。
(select st_PAYMENT from QLT.paymnts P where P.ID_COND=B.ID_COND order by (CASE WHEN P.st_PAYMENT='ES' THEN 1 ELSE 0 END) DESC, TS_INSMNT DESC fetch first 1 rows only)
エラーなしで移植を行うにはどうすれば変更できますか?