SQLTeam.com | Weblogs | Forums

Earliest date in a set of dates given

tsql
sql2008r2

#1

I want to find the earliest date among a set of dates for an activity. Thanks for your time.

For example

Activity ActivityDate


A10 2016-08-01
A10 2016-06-21
A11 2016-06-02
A11 2016-01-09
A11 2016-09-09

The expected result is:

Activity ActivityDate


A10 2016-06-21
A11 2016-01-09


#2

Sorry for the trouble.

I got the answer.

SELECT activity, MIN(ActivityDate) FROM #Temp1 GROUP BY activity