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!

select..... from table...... having max date

John O'TooleJan 29 2007 — edited Jan 29 2007

I'm trying to select the row from a table that has the maximum date. For example, lets say I want the name of the most recently created object in dba_objects. I can do this using a sub-query, but surely there must be an easier way, and querying this way doesn't account for the possibility of two things being created at the exact same time.
I would assume there must be some way of achieving the same result using the HAVING clause, but I can't figure it out right now (it is Monday morning after all).

Any ideas?

SELECT	object_id, object_name, created
FROM	dba_objects 
WHERE	created = (
	SELECT	MAX(created) 
	FROM	dba_objects)
/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 26 2007
Added on Jan 29 2007
7 comments
1,094 views