mike winston mike winston - 1 year ago 71
SQL Question

How to return only the earliest date for each user (users have 100s of dates)

I've read for hours but am getting nowhere, so was wondering if I could get a little help. Here is my problem, which should be simple for experts (trouble is I am a total noob)

enter image description here

I would like to only get each unique user and their earliest time recorded, just like this:

enter image description here

Any thoughts? The simpler the query, the better. Thanks!

Answer Source

You could use a simple GROUP BY with MIN:

SELECT Username, MIN(Datecolumn) As Datecolumn
FROM dbo.TableName
GROUP BY Username
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download