Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Order by in a subquery
"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
![]() |
![]() |