I have a table M
price1 name price2
--------------------------------
88 astérix 80
75 cetautomatix 70
95 panoramix 90
20 assurancetourix 30
105 NULL NULL
And I want to get the max of price2 with corresponding name and price1
So the result I want would be
price1 name price2
--------------------------------
95 panoramix 90
I know that a lot of pretty similar question were asked here and I achieved to find this solution.
SELECT m.price1, m.nom, m.price2
FROM M m
WHERE m.price2 = (SELECT MAX(m.price2) FROM M m);
However I'd like to find a solution where I need only one request (Just one SELECT, not two)
So I tried things like that
SELECT m.price1, m.nom, MAX(m.price2)
FROM M m
Group by m.nom, m.price1
But it doesn't work like i want.
So if someone know a way to do it in only one request it would be really helpfull!
Thanks