1

我什至不确定 SUM 是否是正确使用的函数。这是我的用户视图的样子,它将用户与积分连接起来,并根据团队 ID 从团队表中获取他们的团队名称:

Person  TeamName    Points
10      Team A          500
20      A-Team           20
30      Party People    100 
40      Test!           150
50      WhooHoo         200
60      Party People    750
70      Test!            14

如您所见,有两个人具有相同的团队名称,我想按团队分组显示结果如下:

TeamName        Points
Team A          500
A-Team           20
Party People    850
Test!           164
WhooHoo         200

也许我需要重新开始......这是我必须处理的:

Users           teams
user-id         team-id
name            teamName
points
teamid

任何帮助将非常感激!!谢谢

4

1 回答 1

1
Select teamName, sum(Points) from users, teams 
on user.team-id = team.team-id
group by teamName 
于 2012-12-19T01:28:46.763 回答