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

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL PUZZLE: selecting top 50 salaries in a table

Re: SQL PUZZLE: selecting top 50 salaries in a table

From: TurkBear <johng_at_mm.com>
Date: Fri, 22 Oct 1999 18:48:38 GMT
Message-ID: <3810b099.1088765@super.news-ituk.to>

Does no one read anymore ???

You cannot use the rownum is this way....The first 50 rows returned will meet the rownum condition and then THOSE 50 rows will be sorted...this will NOT give you the top 50 of anything except by random luck....

The process :

Record is returned from database
rownum is incremented
after condition met, result set is sorted...

See the many, many postings on this issue in Dejanews

"Charles Johnson" <charjohn_at_usa.capgemini.com> wrote:

>NetComrade,
>
>The following SQL should work...
>
>select salary from <table_name>
>where rownum <= 50
>order by salary desc
>/
>Essentially, only the first 50 rows of the salary listing is displayed in
>descending order.
>
>clj
>
>NetComrade wrote in message <380f8e89.268436409_at_news.earthlink.net>...
>>Well.. we know how to select top salary, which is select max(salary),
>>but how would I select top 50 records?
>>---------------
>>Andrey Dmitriev eFax: (978) 383-5892 Daytime: (917) 373-5417
>>AOL: NetComrade ICQ: 11340726 remove NSPAM to email
>>
>

  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------    http://www.newsfeeds.com The Largest Usenet Servers in the World! ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==----- Received on Fri Oct 22 1999 - 13:48:38 CDT

Original text of this message

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