Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. teams:
  2. -----------------------
  3. | team_id | team_name |
  4. -----------------------
  5.  
  6. team_results:
  7. ----------------------------------------------------------
  8. | team_results_id | team_id | result_date | won (1 OR 0) |
  9. ----------------------------------------------------------
  10.  
  11. SELECT *, COUNT(*)
  12. FROM
  13. (
  14. SELECT teams.team_id, won
  15. FROM teams
  16. INNER JOIN
  17. (
  18. SELECT team_id, won
  19. FROM team_results
  20. ORDER BY result_date DESC
  21. ) AS team_results ON teams.team_id = team_results.team_id
  22. ) AS a
  23. WHERE won = 0
  24. GROUP BY team_id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement