Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- id || name || team || goals || data
- 1 || Kitten || Pets || 3 || 12
- 2 || Dog || Pets || 2 || 11
- 3 || Kitten || Animals || 5 || 6
- 4 || Kitten || Cats || 4 || 3
- 5 || Dog || Pets || 2 || 9
- name || team || sum(goals) || sum(data)
- Kitten || Pets || 12 || 21
- Dog || Pets || 4 || 20
- select * from table where id in(select max(id) from table group by team)
- SELECT name, team, SUM(goals), SUM(data)
- FROM table t1
- JOIN (SELECT team
- FROM table
- ORDER BY id DESC
- LIMIT 1) t2
- ON t1.team = t2.team
- GROUP BY name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement