Get maximum from aggregated values in a query
-
01-11-2019 - |
문제
I have a table details
it has a column kills
and a column player_slot
and a column match_id
. I want to find the maximum difference between the SUM
of kills
for player_slot
0-4 and 128-132. Can someone give me a hint?
Thats my table details
:
id,
kills,
match_id,
player_id,
player_slot
Thats what I got so far, it's not much:
SELECT SUM(m."kills") AS max_kills
FROM details m
INNER JOIN matches ON matches.id = m.match_id
WHERE m.player_slot IN (0,1,2,3,4)
GROUP BY m."match_id"
SELECT SUM(m."kills") AS max_kills
FROM details m
INNER JOIN matches ON matches.id = m.match_id
WHERE m.player_slot IN (128,129,130,131,132)
GROUP BY m."match_id"
올바른 솔루션이 없습니다
제휴하지 않습니다 dba.stackexchange