Question : Name the most powerful heroes of each race.
Table:
Hero Race Power
a-bomb human 7000
amazo human 7000
ajax cyborg 5000
mephis cyborg 5600
ammo human 1000
ardina alien 2000
jagua alien 200
myntria alien 2300
hyspace alien 2300
...
...
...
and so on.
Now for this data, for the race "human", we have a-bomb and amazo both of whom have the highest power. So my output should include both their names.
My expected output:
Race Hero
human a-bomb
human amazo
cyborg memphis
alien myntria
alien hyspace
Please help.
I tried grouping by race and selecting the max, but that just gives one maximum when the same race has multiple maximum.
SELECT race,hero, max(Power)
FROM heroes_info
GROUP BY race;
My expected output:
Race Hero
human a-bomb
human amazo
cyborg memphis
alien myntria
alien hyspace
My actual output:
Race Hero
human a-bomb
cyborg memphis
alien myntria