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

Home -> Community -> Usenet -> c.d.o.tools -> Re: How to use 'Top' in oracle?

Re: How to use 'Top' in oracle?

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Tue, 26 Sep 2000 11:20:07 +0100
Message-ID: <969963920.23651.0.nnrp-10.9e984b29@news.demon.co.uk>

There is a change in 8.1, and rownum can be applied after order by, but I think you have to use an inline view to achieve it, viz:

select * from
(

    select product_name
    from product
    order by price DESC
)
where rownum<=3
;

This is a side-effect of allowing ORDER BY inside views rather than an explicit re-implementation of the ROWNUM concept.

--

Jonathan Lewis
Yet another Oracle-related web site:  http://www.jlcomp.demon.co.uk

Niall Litchfield wrote in message <8qpsat$4j5$1_at_soap.pipex.net>...

>"NetComrade " <andreyNSPAM_at_bookexchange.net> wrote in message
>news:37ed628d.26437414_at_news.earthlink.net...
>> select product_name from product order by price where rownum<=3 in 8i
>> only.
>
>Does this mean that rownum has changed in 8i to work on the basis of rank.
I
>must have missed that one if it did, and I kinda doubt it. Jonathon and
>basavaraj have given the two text book ways to achieve this.
>
>
>--
>Niall Litchfield
>Oracle DBA
>Audit Commission UK
>
>
Received on Tue Sep 26 2000 - 05:20:07 CDT

Original text of this message

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