如何在SQL中每周输出球员得分总和的球队得分 [英] How do I output a team score which is sum of player scores weekly in SQL

查看:168
本文介绍了如何在SQL中每周输出球员得分总和的球队得分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在名为b_scores的表中有保龄球队和球员记录.
需要每周输出一个战队得分,这是单个球员得分的总和.
我尝试过的只给了我第一名的成绩?

我将如何调整此代码以在一周的团队基础上给出结果?

如果有问题,我正在使用2012年以前的SQL.

我尝试过的事情:

SELECT `Week`,`Date`,`TeamNum`, 

(SUM(Gm1) + SUM(Gm2) + SUM(Gm3)) as "GmTotal"

FROM b_Scores 

GROUP BY `Week`



结果:

 Week 	Date 	TeamNum 	GmTotal 	
01 	2016-09-12 	4 	1372
02 	2016-09-19 	4 	1161
03 	2016-09-26 	4 	923
04    2016-10-03 	4 	1490
05 	2016-10-10 	4 	2060

解决方案

尝试:

  SELECT 星期,SUM(Gm1),SUM(Gm2),SUM(Gm3) FROM  b_Scores   BY 


I have bowling team and player records in a table called b_scores.
Need a weekly output of one line team score which is a sum of individual player scores.
What I have tried gives me only the 1st player results?

How would i adjust this code to give results on a team basis for the week?

I am using pre 2012 SQL if it matters.

What I have tried:

SELECT `Week`,`Date`,`TeamNum`, 

(SUM(Gm1) + SUM(Gm2) + SUM(Gm3)) as "GmTotal"

FROM b_Scores 

GROUP BY `Week`



Results:

 Week 	Date 	TeamNum 	GmTotal 	
01 	2016-09-12 	4 	1372
02 	2016-09-19 	4 	1161
03 	2016-09-26 	4 	923
04    2016-10-03 	4 	1490
05 	2016-10-10 	4 	2060

解决方案

Try:

SELECT Week, SUM(Gm1), SUM(Gm2), SUM(Gm3) FROM b_Scores GROUP BY Week


这篇关于如何在SQL中每周输出球员得分总和的球队得分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆