I have a table "products" that has the columns "name" and price". There are multiple prices for the same name. The table looks like
shampoo 7
shampoo 10
shampoo 8
bread 1
bread 1.5
water 0.5
water 0.7
......
I want the row with the max price. I tried
select name, price
from products
group by name
having max(price);
Note: My problem isn't that, but I wanna know the logic behind the solution. Thanks.