Re: rownum

From: (wrong string) ¾ç±â¿µ <kiyoungy_at_usc.edu>
Date: Tue, 06 Feb 2001 05:01:46 GMT
Message-ID: <_yLf6.179696$y9.31304880_at_typhoon.we.rr.com>


Hi,

well, if you use Oarcle 8i (8.1.5 or later) you can use 'order by' clause in a inline view. For example,

select * from
(select * from emp order by salary desc) where rownum < 10

will give you the TOP 10 employees whose salaries are highest. If you don't use Oracle 8i, you must be in trouble ^^;, and must write something like co-related join.

Hope this helps,
Kiyoung..

"Chaz" <chaz_at_hates.spam> wrote in message news:3a7f7a4b_at_newsserver1.intergate.ca...
> can anyone help me find a way to limit the number of records returned in a
> select statement? here's what i mean:
>
> in MS SQL Server, the "TOP n" kewords (as in "SELECT TOP 10 fname FROM
> table") specify how many records *out of the resultset generated from the
> rest of the select statement* are actually returned. in Oracle, the
 closest
> thing I've found is "WHERE rownum <= n". But this rownum is an internal
> index, so it doesn't limit the resultset to the top n of that resultset,
 but
> to records whose rownum is <= n. Theres a huge difference here, and I'm
> totally stumped.
>
> is there a similar keyword in Oracle?
> do i have to spend the next week writing a stored proc to achieve this?
> any clues?
>
> thx in advance.
>
>
Received on Tue Feb 06 2001 - 06:01:46 CET

Original text of this message