Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Simple Query Help
You can't use an order by in a subquery.
The ORDER BY clause is subject to the following restrictions:
If the ORDER BY clause and the DISTINCT operator both appear in a SELECT
statement, the ORDER BY clause cannot refer to columns that do not appear in
the select list.
The ORDER BY clause cannot appear in subqueries within other statements.
The ORDER BY clause can contain no more than 255 expressions.
-- Robert Fazio, Oracle DBA rfazio_at_home.com remove nospam from reply address http://24.8.218.197/ "Gabriel Millerd" <millerd_at_ns1.rli-net.net> wrote in message news:8gjoff$f4a$1_at_news.powerisp.com...Received on Fri May 26 2000 - 00:00:00 CDT
>
> What is wrong with this query?
>
> select * from (select a from tablename where b = 1 order by ts desc) where
rownum < 100
>
> I get a ORA-0097: missing right parenthesis.
>
> This works just fine however (but not what i want)
>
> select * from (select a from tablename where b = 1) where rownum < 100
>
> Is there an easier way or a work around?
>
> ---
> Gabriel Millerd | Let them hate, so long as they fear. -Lucius
> Sith Admin | Accius, Fragment
> http://sabbat.org |