Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Order by in a subquery

Re: Order by in a subquery

From: Ed Avis <ed_at_membled.com>
Date: 28 Feb 2004 12:57:53 +0000
Message-ID: <l1llmnjr8u.fsf@budvar.future-i.net>


"bob" <bobo_at_yahoo.fr> writes:

>SELECT r_num, T.Field1, T.Fiel2
>FROM (
> SELECT rownum as r_num,
> Field1,Field2
> FROM table1
> order by field1
> ) T
>where r_num between 1 and 5
>
>I have a problem with the 'Order by' clause, but I need to sort the
>records in the subquery.

Why? Even if you did sort the records in the subquery, there's no guarantee that they would still be sorted in the same order when returned from the main query. (It might happen with a particular Oracle version, but it doesn't have to.)

If you need a particular ordering put the order by clause in the top-level query.

-- 
Ed Avis <ed_at_membled.com>
Received on Sat Feb 28 2004 - 06:57:53 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US