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: limit

Re: limit

From: Michael L. Hostbaek <michDEL_THIS_at_bsd.fr.eu.org>
Date: 23 Jan 2002 09:27:22 GMT
Message-ID: <slrna4t0ap.1srj.michDEL_THIS@freebsdcluster.dk>


Ed prochak tried to tell us something, and all I got was:
> "Michael L. Hostbaek" <michDEL_THIS_at_bsd.fr.eu.org> wrote in message news:<slrna4r0fh.1nbn.michDEL_THIS_at_freebsdcluster.dk>...
> > Michael L. Hostbaek tried to tell us something, and all I got was:
> ORACLE doesn't have a 'numrow' function.

yeah, sorry I got it mixed up..

>
> But to answer your question, use:
>
> select * from yourtable where rownum <11;
>

yup, I got that working to.
>
> (Before your complain those are the first 10 rows, Please define what
> you means by LAST rows. Most people asking this question are thinking
> in terms of FILE based databases. ORACLE is a Relational database. In
> a relational database it doesn't make any sense to ask for the "last
> rows" of a table.)

OK. I get that. But let us say, that I have a table with to fields: some_entry varchar()
when date()

Now, I would like to get the 10 latest added rows (according to the when field)
THe only thing, Oracle let's me do is the following:

        select * from some_table rownum <= 10 order by when desc;

However, with this statement the only thing getting sorted is the 10 rows I have selected. I would like for Oracle to sort the table, *before* I grap the 10 rows.

> Finally, if you still really want to do this, look into using a cursor
> in PL/SQL.

Tell me more ;) Could you point me to a link where I could learn more about this ?

Thanks..

-- 
Regards,
Michael L. Hostbaek
-= So long, and thanks for all the fish.. =-
Received on Wed Jan 23 2002 - 03:27:22 CST

Original text of this message

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