I have a simple table Customers
with fields id, name, rating, seller_id
.
The result of query
select seller_id, MAX(rating)
from Customer
group by seller_id
is the customers grouped by seller_id
with max values of the rating. Like this:
seller_id rating
2 17
3 20
4 17
How to modify this query to get customer's id additionally?
If I add id
to SELECT
I get an error, that I should add id
to grouping. But I want only get above shown values with id specified. Does anyone know how to do this? Thanks.