es kko tādu uz ātro roku samurgoju :D
sintakse nav pareiza, bet ceru ka ideja ir skaidra
SELECT komanda, SUM(rez) as rezultats
FROM
(SELECT SUM(km1_rez) as rez, km1 as komanda
FROM SPELES
GROUP BY km1
UNION
SELECT SUM(km2_rez) as rez, km2 as komanda
FROM SPELES
GROUP BY km2) as sr
GROUP BY komanda
ORDER BY rez DESC