繁体   English   中英

对来自同一列的不同值求和

[英]Sum different values from same column

我需要按小时计算所有站点的所有温度:

station       hour     temperature
-----------------------------------
100             1          2
101             1          2
100             2          4
101             2          4

我希望结果是这样的:

hour     temperature
---------------------
1            4
2            8

...站100的温度被添加到站101(2 + 2 = 4),等等。

最好的方法是什么?

提前致谢。

尝试这样的事情:

select hour,sum(temperature)
from MyTable
group by hour
select hour,sum(temperature) from table_name group by hour;

您需要使用GROUP BY。

SELECT hour, SUM(temperature) FROM myTable GROUP BY hour
Select hour,SUM(temperature) FROM Table GROUP BY hour

暂无
暂无

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

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