简体   繁体   English

SQL查询SELECT表将所有其他两个相等的值求和

[英]SQL Query SELECT table that sum all values where two others are equal

I have the following table ("Have"). 我有下表(“有”)。 What would be a proper way to SELECT a table where you sum the value of C where A and B are equal. 选择一个将A和B相等的C值相加的表的正确方法是什么。 So that you get the result displayed in "Want". 这样您就可以在“ Want”中显示结果。

在此处输入图片说明

然后使用group by然后求和

select A, B, sum(c) from your_table group by A, B

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

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