Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 442
mike winston Avatar asked Oct 10 '16 12:10

mike winston


1 Answers

You could use a simple GROUP BY with MIN:

SELECT Username, MIN(Datecolumn) As Datecolumn
FROM dbo.TableName
GROUP BY Username
like image 182
Tim Schmelter Avatar answered Sep 22 '22 19:09

Tim Schmelter