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: Hod do I select the last 100 records of a Table.

Re: Hod do I select the last 100 records of a Table.

From: Jerry Gitomer <jgitomer_at_hbsrx.com>
Date: Tue, 22 Jun 1999 09:16:38 -0400
Message-ID: <7ko7nu$jr7$2@autumn.news.rcn.net>


I tried this and it works.

regards

Jerry Gitomer


From: shailaja <saila_at_irmac.com>
Subject: Re: SQL question.
Date: Tuesday, June 15, 1999 4:48 PM

Give the below query and while running the query give the input which represents how many records u want to see from last. Let us say u want to view the last 10 records as u said give the input as 10.

"select * from (select e.*,rownum p from emp e) where p > (select count(*)-&1 from emp)"

Shailaja

Kenneth C Stahl wrote in message <376F7FB1.7FA40F50_at_lucent.com>...
>I'll give you a kluge fix. It isn't pretty or elegant, but it will work.
>
>Select the first 100 rowid's into a pl/sql table. Then read the table from
>the highest to the lowest index value and use the rowid to select the row.
>
>Keep this in mind though - unless you have some type of natural key (ssn,
>for instance), the whole concept of record order is meaningless. In essence
>the order becomes whatever order you want it to be. So really, there is no
>particular concept of the first 100 records, last 100 records or even first
>and last records. The first record will always be whatever your cursor
>returns as the first record.
>
>Ken
>
>Glen Gray wrote:
>
>> I know it sounds like a simple request but I can't get it to work.
>>
>> If I do :
>>
>> select * from table_name where rownum<=100 order by recordid desc
>>
>> I get the first 100 records back in reverse order. I haven't been able
>> to do a select into #tmp_table either. I need to get this working fairly
>> quickly so any help would be greatly appreciated.
>
Received on Tue Jun 22 1999 - 08:16:38 CDT

Original text of this message

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