0
Good afternoon!
I have the following situation: I have a table with the results of some football games. I managed to assemble a SELECT and assign 3 points to the winner and 1 points to the draws. Now I need to add all the points of each team and assemble a table from the first to the last placed. What I’m unable to do and that sum of points. Follow the SELECT I’ve done so far:
SELECT CDJOGO, CDEQUIPE, NMABREVIADO, CDEQUIPEVENCEDORA,
CASE
WHEN CDEQUIPE = CDEQUIPEVENCEDORA THEN +3
WHEN CDEQUIPEVENCEDORA IS NULL THEN +1
END AS PONTOS
FROM EQUIPE AS E
JOIN JOGO AS J ON E.CDEQUIPE = J.CDEQUIPECASA OR E.CDEQUIPE = J.CDEQUIPEVISITANTE
GROUP BY CDJOGO, CDEQUIPE, NMABREVIADO, CDEQUIPEVENCEDORA
Edit your question and put the table structure.
– João Martins