Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL中重复值的计数_Sql - Fatal编程技术网

SQL中重复值的计数

SQL中重复值的计数,sql,Sql,我有以下资料 Game_id | Team 47 | 1 47 | 1 23 | 2 31 | 1 41 | 2 47 | 8 我想从所有比赛中统计每个队的人数 我希望是这样的: Team 1 has made 3 goals Team 2 has made 2 goals Team 8 made 1 goal. 我如何才能做到这一点?使用COUNT()和分组方式,如: SELECT Team, COUNT(Team) FROM m

我有以下资料

Game_id | Team
47      | 1
47      | 1
23      | 2
31      | 1
41      | 2
47      | 8
我想从所有比赛中统计每个队的人数

我希望是这样的:

Team 1 has made 3 goals
Team 2 has made 2 goals
Team 8 made 1 goal.
我如何才能做到这一点?

使用
COUNT()
分组方式,如:

SELECT Team, COUNT(Team) FROM myTable GROUP BY Team

做一个分组依据,使用COUNT()聚合函数。这就是我要找的。非常感谢。我以为这很难解决。