SELECT plaka, party_id, sum(inf) i
FROM party_sehir
GROUP BY party_id, plaka
This is my sub-query and the results are:
plaka party_id i
34 1 42
34 2 9
35 1 11
35 2 26
from these results I want to get maximum i
of every plaka
and rows party_id
, like this:
plaka party_id i
34 1 42
35 2 26
I mean the maximum for each plaka
. I also tried:
SELECT *
FROM ( SELECT plaka, party_id, sum(inf) i
FROM party_sehir
GROUP BY party_id, plaka ) t1
GROUP BY plaka
HAVING i >= max(i)
It didn't work; is anyone able to help?
thank you