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!

how to return only the most recent row?

789736Jul 9 2012 — edited Jul 9 2012
Hi guys,

I have a question which I am hoping is not too difficult but I just am not sure how to do it. I need to run a query on a table which may bring back multiple rows for my criteria, however I only want to bring back 1 of these multiple rows and the one I want to bring back has to be the most recent. I do have a date_created column on my table as well as a date_last_updated column. So basically using the select statement below as an example this query could return lets say 5 rows, I however only want it to return the most recent row and the most recent row is determined by the date_last_updated (which will only be populated if the record has been updated otherwise it is null) or the date_created fields.

select * from my_table
where model_id = 234

Any help on this matter would be greatly appreciated.

Thank you.
This post has been answered by Solomon Yakobson on Jul 9 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2012
Added on Jul 9 2012
3 comments
313 views