Oracle DB Syntax for Unique Records

I have a table that has two fields: username and entrydate. I am trying to figure out the query to pull the latest combination of the two or most recent combination based upon the entrydate.

So for example:

user1, 01_May_2013
user1, 29_May_2013
user2, 01_April_2013

The SQL I am looking to run should pull:

user1, 29_May_2013
user2, 01_April_2013

Since I only want the most recent record in my pull I would only get the unique values and the most recent entry for user1.
Who is Participating?
slightwv (䄆 Netminder)Connect With a Mentor Commented:
Something like:

select username, max(entrydate) from table_name group by username;

or if the actual requirements are more complex than what you posted, you might need to use row_number:

select username, entrydate from (
select username, entrydate,row_number() over(partition by username order by entrydate desc) myrn
from table_name
where myrn=1;

The unique keyword in your post is a little confusing.  If the above queries don't work, please ad to your test case and explain more about what you are after.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.