Teradata most recent date

Hi All,
    I am trying to pull information from a table that has multiple dates.  Let's say it was a table tracking what days people went to the gym.  Every time the person scans his or her card, another row of data is created.  Let's say I only wanted to pull in the most recent visit for each gym member and the field name for the date is contact_date.  

I essentially want something like:

select Name, Contact_Date, Address from  TABLE1
where contact_date = most recent date of all the visits that gym member has.

I need the code to tell teradata to pull in the most recent date.
akatz66Asked:
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.

SharathData EngineerCommented:
You can try any of these queries.

select Name, Contact_Date, Address from  TABLE1 as t1
where contact_date = (select max(t2.contact_date) from TABLE1 as t2 where t1.Name = t2.Name)

(or)

select t1.Name, t1.Contact_Date, t1.Address from  TABLE1 as t1
JOIN (SELECT Name,max(Contact_Date) as Contact_Date FROM TABLE1 GROUP BY Name) as t2
ON t1.Name = t2.Name and t1.contact_date = t2.contact_date
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
Enterprise Software

From novice to tech pro — start learning today.