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: Selecting last n rows

Re: Selecting last n rows

From: Mark G <mgumbs_at_nospam.hotmail.com>
Date: Wed, 30 Jun 1999 10:14:10 +0100
Message-ID: <3779dd85.0@145.227.194.253>


This code won't work i'm afraid ;-(
The rownum method only works in simple queries.

Try

select * from the_table t1
where 10000 > (select count(primary_key) from the_table t2

            where t1.primary_key < t2.primary_key);

Just replace primary key with the primary key from your table.

M

Vincent Lemaire wrote in message <7lcm92$rhj$1_at_minus.oleane.net>...
>I think you should try with the rownum pseudocolumn
>something like :
>
>select * from the_table
>where rownum >= (select max(rownum)-10 from the_table);
>
>if it is what you expected...?
>
>
Received on Wed Jun 30 1999 - 04:14:10 CDT

Original text of this message

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