Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: extract Top Ten order by date
You must be using a very old, outdated version of Oracle, at least 8.0
or earlier, when an order by clause was not allowed in a subquery.
That sort of query works fine in currently supported versions, as shown
below:
scott_at_ORA92> SELECT *
2 FROM (SELECT a.*
3 FROM scott.emp a 4 ORDER BY a.hiredate)
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
In 8.0 you have to use something like this, which is less efficient:
scott_at_ORA92> SELECT *
2 FROM scott.emp b
3 WHERE 5 >=
4 (SELECT COUNT (*) 5 FROM scott.emp a 6 WHERE a.hiredate <= b.hiredate)7 ORDER BY hiredate
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
You should upgrade your database to a currently supported version, at least 9i. Received on Mon Sep 26 2005 - 16:05:50 CDT