Adham
Adham

Reputation: 64904

Select the max number of repeated records in a SQL table

If I have multiple records in a SQL table like:

name                score
...................................
sami                55
ali                 140
sami                60

I want to select the highest score for each player. The expected result would be:

ali ,140
sami, 60

Upvotes: 1

Views: 1307

Answers (2)

Rahul
Rahul

Reputation: 77896

Select name,max(score) as 'Highest Score' from gametable group by name;

Upvotes: 1

Sergey Rybalkin
Sergey Rybalkin

Reputation: 3026

Looks like it is as simple as that:

SELECT name, MAX(score) FROM <table_name> GROUP BY name

Upvotes: 1

Related Questions