SQL sum函数的使用方法
答案:4 悬赏:80 手机版
解决时间 2021-03-05 19:40
- 提问者网友:寂寞梧桐
- 2021-03-04 19:04
SQL sum函数的使用方法
最佳答案
- 五星知识达人网友:天凉才是好个秋
- 2021-03-04 19:11
select class,sum(math),sum(chinese),sum(math+chinese)
from table
group by class
from table
group by class
全部回答
- 1楼网友:北方的南先生
- 2021-03-04 20:57
declare @SumMath int,@SumChinese int,@SumMathChinese int
select @SumMath=sum(math),@SumChinese=sum(Chinese) from 表名 where Class=条件
set @SumMathChinese=@SumMath+@SumChinese
select @SumMath=sum(math),@SumChinese=sum(Chinese) from 表名 where Class=条件
set @SumMathChinese=@SumMath+@SumChinese
- 2楼网友:罪歌
- 2021-03-04 20:08
选中你想要求和后放在的位置,然后在fx函数后面写上你的函数=SUM(A2:A21,B2:B21) 求和是这样的函数
这是求A列 2 -21 和B列 2-21的和
同样,求行的话应该写作=SUM(A2:H2,B3:G3)
这就是求第二行从A到H和第三行 B到G的和
这就是多行多列求和 中间用半角的逗号隔开
第二种方法:在选择函数参数的时候,如下图,点击参数1,选中要求行的第一行,点击2,选择要求和的第二行,最后点击确定
- 3楼网友:鱼忧
- 2021-03-04 19:31
Select class,Sum(a)
From
(
Select class,Sum(math) a
From 表名
Group By class
Union All
Select class,Sum(chinese)
From 表名
Group By class
)a
Group By class
From
(
Select class,Sum(math) a
From 表名
Group By class
Union All
Select class,Sum(chinese)
From 表名
Group By class
)a
Group By class
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯