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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How Do I Get the Top 50 from a Query?

Re: How Do I Get the Top 50 from a Query?

From: me <gingergrrrl_at_hotmail.com>
Date: Fri, 24 Jul 1998 13:17:28 -0400
Message-ID: <35B8C1A7.D296E15D@hotmail.com>


Do you want the first 50 records from your query? or the top 50 meaning the 50 highest values?
If you want the first 50 records from your query you can add "and rownum <= 50" to your where clause. Just remember if you do this it will select the first 50 records that match your criteria before sorting (not according to your order by clause).

anthony.savoca_at_spcorp.com wrote:

> I am writing a query with PL/SQL and I want to get only the top 50 records
> returned in the result set. I could use a cursor to go through the results
> and stop after 50, but I was hoping there might be a way in PL/SQL to only
> get the top 50 returned to me. This way I could use a select in the from
> clause to get only the data I need. I guess it would work similar to the TOP
> clause in Access. Any ideas would be appreciated. If you could, please
> respond via email. If I get a good solution, I'll repost it to this group.
> Thanks!!
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Received on Fri Jul 24 1998 - 12:17:28 CDT

Original text of this message

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