I have 1 relevant table for this question, award :
----------------------------------------
| award |
----------------------------------------
| id | name | URL | country_id | point |
----------------------------------------
1 | A | a | 1 | 120
2 | A | b | 0 | 60
3 | A | b | 2 | 80
4 | B | c | 0 | 50
5 | B | d | 1 | 70
I want to be able to get for a list of given countries, the corresponding different awards (a same award has the same name) with the highest value for the column point.
So I tried ordering my request by point DESC, and grouping by name, but it didn't do the trick, I didn't get the right number of points nor the right URL.
I know I could do that easily by getting all the data from the table then keeping only the row with the best number of points, but there must be a way to do that with SQL only !
The request I tried was :
SELECT name, URL, point FROM award WHERE country_id IN (0,1) ORDER BY point DESC GROUP BY name