我尝试在Oracle Decode函数中使用ORDER BY
编译器说缺少右括号
DECODE(controlNumber, NULL, myOldNUmber, (SELECT myNewNumber FROM tableA A, tableB B WHERE A.control_id = B.control_id AND A.other_id = B.other_id) ) AS finalnumber,
似乎同样的查询没有看到为什么ORDER BY
在这里不被接受:
DECODE(controlNumber, NULL, myOldNUmber, (SELECT myNewNumber FROM tableA A, tableB B WHERE A.control_id = B.control_id AND A.other_id = B.other_id ORDER BY createdTime)) AS finalnumber,
答案 0 :(得分:2)
我目前无法测试,但请尝试...
DECODE(controlNumber, NULL, myOldNUmber, (SELECT myNewNumber FROM (SELECT myNewNumber FROM tableA A, tableB B WHERE A.control_id = B.control_id AND A.other_id = B.other_id ORDER BY createdTime) WHERE rownum=1) AS finalnumber