Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我试图从我的表中选择多个结果。我有用户的名字和他们的分数。用户被分成组。
必填字段:groupnumber、score
我正在尝试使用以下方法查找每个组的总分、平均分、最低分和最高分:
SELECT groupnumber, SUM(score), AVG(score), MIN(score), MAX(score) FROM players;
不幸的是,这不起作用。它只显示我的第一个字段的结果。
你需要一个 GROUP BY 子句
SELECT groupnumber, SUM(score), AVG(score), MIN(score), MAX(score) FROM players GROUP BY groupnumber;
尝试
SELECT groupnumber, SUM(score), AVG(score), MIN(score), MAX(score) FROM players GROUP BY groupnumber