You have these insert in the table
I'd like an sql and it returns me the team total points type:
time - points
Uruguay - 9
russia - 6
arabia - 3
Egypt - 0
See if it caters to you:
with pontuacao_times as(
select time1 as time
,pontostime1 as pontos
from Sua_tabela
union all
select time2 as time
,pontostime2 as pontos
from Sua_tabela)
select time
,pontos
from pontucao_times
group by time, pontos;
This code resolves:
SELECT TIME, SUM(J.PONTOS) AS PONTOS FROM (
SELECT TIME1 AS TIME, PONTOSTIME1 AS PONTOS
FROM JOGOS
UNION ALL
SELECT TIME2 AS TIME, PONTOSTIME2 AS PONTOS
FROM JOGOS) AS J
GROUP BY TIME
ORDER BY PONTOS DESC
Results in:
TIME PONTOS
uruguai 9
russia 6
arabia 3
egito 0
See working at link