Avatar of deanlee17
deanlee17
 asked on

SQL query for this scenario

Hi guys,

Im sure the following can be done in a single query:

I have a table with usernames and dates when they were last active. I need a query to collect the username and the last date they were online. Each username can appear more than once and they will have various dates, ie:

Username            Date

John Smith            01/01/12
John Smith            03/11/12
John Smith            07/12/12
Simon Jones          11/06/13
Simon Jones          15/02/13
Simon Jones          18/09/13

Cheers,
Dean
SQL

Avatar of undefined
Last Comment
Rob

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rob

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Rob

That's assuming that the "Date" column is a date field.  If it is stored as text then you'll need to convert it to a date.  In MySQL for example you use str_to_date()
deanlee17

ASKER
Yes it is in date field.

Perfect thanks.
Rob

Great - let me know if you have any more issues :)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy