Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PL/Sql code to get last record

Status
Not open for further replies.
Apr 20, 2000
41
US
Hi, I looking for some help on some Pl/SQL code for oracle 7.34 that does a select on a table and gets the last entry from a repating record set of data. No index or key exists, just repeating records of data...

row#, date, weight, status
1, 20020101, 100.0, 1
1, 20020201, 500.5, 3
1, 20020301, 333.3, 4
.
.
.
.

I need to get the last record from the data set. Do I use FETCH and serially read thru each record til the row# changes?

thanks
 
Hi,
the following should work - use MAX ROWID to get the last record:

SELECT a,b,c,d FROM t WHERE rowid = (select max(rowid) from t);

ROWID is an indexed field, so this shouldn't take too much processing.

Regards,
Jeremy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top