Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Hod do I select the last 100 records of a Table.
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 - 07:21:05 CDT