简体   繁体   English

使用 SQL 查询对总计进行分组

[英]Grouping Totals With SQL Query

Here's the situation:这是情况:

I have a table that has two data columns:我有一个包含两个数据列的表:

Number | Value
     0 |    11
     0 |    10
     0 |    12
     1 |    10
     1 |    10
     1 |    11
     2 |    11
       .
       .
       .

And so on...等等...

I would like to create a query that presents the totals for the different numbers separately, so it would end up being like so:我想创建一个查询,分别显示不同数字的总数,所以它最终会像这样:

Number | Total
     0 |    33
     1 |    31
     2 |    11
       .
       .
       .

I've tried applying a simple SUM(Value) into my Query, but I can't seem to get it right.我试过将一个简单的 SUM(Value) 应用到我的查询中,但我似乎无法正确使用。

Any help would be greatly appreciated.任何帮助将不胜感激。

select number , sum(value) as "total" from tablename
group by Number 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM