How to only get one entry per record when there are multiple entries? I just want the first entry per person.

I am designing a report in SRS but need help with the following issue:

In my list of values I have 2004 records but only have 931 distinct names. My table looks like this:

name,    place                   day
smith      bathroom            12/04/2007
smith      bedroom              12/05/2007

What I need is to have only one smith come up with the most recent day to come up. Distinct wont work because i would get both entries. So I need one entry per name. I was thinking of using a self join but I could not figure out how to implement it.

richeckerAsked:
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.

erikTsomikSystem Architect, CF programmer Commented:
select * from tblname a left join b where a.name=b.name and some date functions
0
chapmandewCommented:
select name, max(date) from table
group by name
0
richeckerAuthor Commented:
I probably was not clear enough...

Here is my table:

first name      last name       address                 city                        dob
john               smith               111 e street          hicksville               01/01/1950
john               smith               111 e st                hicksville                01/01/1950



The address fields are similar but the names will come up twice when querying because of the two separate addresses. How do I only get one name and only one address to come up. Max didnt work.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

richeckerAuthor Commented:
The left join did not seem to work either.
0
chapmandewCommented:
select name, max(address), max(date) from table
group by name
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
MaduKpCommented:
select
distinct first name, last name , address,city,
max(dob)
from
table
group by first name, last name, address, city

But I am confused with your address
-      If the addresses in the DB are 111 e street and 111 e st then those are two distinct addresses, hence it will be count in to two rows.
-      If your table has the two addresses spelled in the above manner and still those are mean to be one address, then, it is a data issue, which is out of the scope that we are talking here.

 Any feedback will be appreciated.
0
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
DB Reporting Tools

From novice to tech pro — start learning today.