Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. id || name || team || goals || data
  2. 1 || Kitten || Pets || 3 || 12
  3. 2 || Dog || Pets || 2 || 11
  4. 3 || Kitten || Animals || 5 || 6
  5. 4 || Kitten || Cats || 4 || 3
  6. 5 || Dog || Pets || 2 || 9
  7.  
  8. name || team || sum(goals) || sum(data)
  9. Kitten || Pets || 12 || 21
  10. Dog || Pets || 4 || 20
  11.  
  12. select * from table where id in(select max(id) from table group by team)
  13.  
  14. SELECT name, team, SUM(goals), SUM(data)
  15. FROM table t1
  16. JOIN (SELECT team
  17. FROM table
  18. ORDER BY id DESC
  19. LIMIT 1) t2
  20. ON t1.team = t2.team
  21. GROUP BY name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement