Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT team, SUM(score) AS totalscore FROM(
- SELECT r1name AS team, redscore AS score, round, game, year FROM matches
- UNION
- SELECT r2name AS team, redscore AS score, round, game, year FROM matches
- UNION
- SELECT r3name AS team, redscore AS score, round, game, year FROM matches
- UNION
- SELECT b1name AS team, bluescore AS score, round, game, year FROM matches
- UNION
- SELECT b2name AS team, bluescore AS score, round, game, year FROM matches
- UNION
- SELECT b3name AS team, bluescore AS score, round, game, year FROM matches
- ) AS scores WHERE year = '2017' GROUP BY team
- ORDER BY totalscore DESC, team ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement