Re: rownum

From: Biss Is Ignorance <bliss_is_ignorance_at_hotmail.com>
Date: Tue, 6 Feb 2001 18:26:16 +0800
Message-ID: <3a7fd18c.0_at_news2.tm.net.my>


hi,

i think i don't understand what you want.... but from what i can figure out ur problem seems for example
Select sales_amt from sales;
now u want to display the top 10 records

if that's the case u could try
Select sales_amt from sales where rownum <= 10 order by sales_amt;

however this is not the most effective method in terms of performance... u should as far as possible use sub-query to get the result...

lemme know if this is ur basic query n then we'll work it out...

regards.

"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 - 11:26:16 CET

Original text of this message