Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. SELECT team, SUM(score) AS totalscore FROM(
  2. SELECT r1name AS team, redscore AS score, round, game, year FROM matches
  3. UNION
  4. SELECT r2name AS team, redscore AS score, round, game, year FROM matches
  5. UNION
  6. SELECT r3name AS team, redscore AS score, round, game, year FROM matches
  7. UNION
  8. SELECT b1name AS team, bluescore AS score, round, game, year FROM matches
  9. UNION
  10. SELECT b2name AS team, bluescore AS score, round, game, year FROM matches
  11. UNION
  12. SELECT b3name AS team, bluescore AS score, round, game, year FROM matches
  13. ) AS scores WHERE year = '2017' GROUP BY team
  14. ORDER BY totalscore DESC, team ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement