以下查询
SELECT JOB_TYPE, CLASS, JOB_RUN_START, JOB_RUN_FINISH, JOB_STATUS, JOB_PID FROM
(SELECT * FROM ARCHIVE_JOBS ORDERBY JOB_RUN_START ASC ) WHERE ROWNUM <=6;
产生错误:
第1行的错误:ORA-00907:缺少右括号
有人知道为什么吗?
答案 0 :(得分:2)
它是order by
,你错过了子查询的别名。我使用X
作为别名
SELECT JOB_TYPE, CLASS, JOB_RUN_START, JOB_RUN_FINISH, JOB_STATUS, JOB_PID
FROM
(
SELECT * FROM ARCHIVE_JOBS
ORDER BY JOB_RUN_START ASC
) X
WHERE ROWNUM <=6;
答案 1 :(得分:0)
尝试将ORDERBY
替换为ORDER BY
ORDERBY不是关键字,因此mysql将其视为查询的FROM
部分(即表格),表格列表应以,