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.
dlnewman70Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) 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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.