Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

last or oldest record in a oracle database table

773020Sep 6 2012 — edited Sep 6 2012
I want to fetch oldest record in database table based on llast updated date ; I tried following queries..it gave me different results

SELECT EVENT_ID, RETENTION_TS
FROM ( SELECT EVENT_ID, RETENTION_TS, RANK() OVER (ORDER BY RETENTION_TS) RETENTION_TS_RANK
FROM EVENT )
WHERE RETENTION_TS_RANK <= 1;

select * from EVENT where rowid=(select min(rowid) from EVENT);

SELECT *
FROM (select * from EVENT ORDER BY RETENTION_TS) EVENT2
WHERE rownum <= 1
ORDER BY rownum DESC;

Above query takes like 10 to 20 mins to return me the record.

Thanks in advance..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 4 2012
Added on Sep 6 2012
7 comments
7,573 views