Jason Wells
Jason Wells

Reputation: 889

Selecting the min value in a SQL result set

Using SQL Server 2012, I need to select the minimum date from a record set which is as follows.

personID    score
________    _____
 2            10
 2            15
 2            25
 3            73
 3            15

I would like my result set to be as follows

personID     score
________     _____
2              10
3              15

So essentially a single result set with the lowest score for each person. I have tried various forms of grouping and min and cannot seem to get it. I feel like this should be simple :(

Upvotes: 0

Views: 1406

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172458

You may try like this:-

select personID, min(score) as Score from table group by personID

Upvotes: 3

Related Questions