Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Top N in Oracle 8.0.5
Sybrand Bakker <postbus_at_sybrandb.demon.nl> wrote in message news:<j5e1iu0m4lhja02v295t4bk3gksqvh0f7m_at_4ax.com>...
> On Mon, 1 Jul 2002 13:20:19 -0400, "ivan vasquez" <ivan_at_itos.uga.edu>
> wrote:
>
> >Hi,
> >
> >How do I create a top-N query in Oracle 8.0.5?
> >
> >The top-N has to happen after sorting the input, but ordered subqueries
> >weren't allowed prior to 8i. All the documentation I've found is related to
> >8i, still no luck with this version!
> >
> >INSERT INTO PA_ASSIGN
> >SELECT * FROM (
> > SELECT *
> > FROM PA_SELECT
> > WHERE code = xPlSqlVariable1
> > ORDER BY col1, col2, col3
> >WHERE ROWNUM <= xPlSqlVariable2;
> >
> >Any hints are greatly appreciated.
> >
> >Thanks,
> >Ivan.
> >
> Upgrade to something supported
>
> Regards
>
>
> Sybrand Bakker, Senior Oracle DBA
>
> To reply remove -verwijderdit from my e-mail address
Unfortunately not all us have the ability to upgrade for various business reasons, surely you understand that?
As for teh original question, search through the group it has been
addressed many times with as many various solutions
(my favourite
x=1;
for c_cur in (select * from table order by)loop
insert into tamp values (c_cur. ....);
if x = 5 then
exit;
end if;
x=:=x+1;
end loop;
)
Bryan Received on Tue Jul 02 2002 - 06:59:49 CDT
![]() |
![]() |