内连接求和 SQL [英] Inner join sum SQL
本文介绍了内连接求和 SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试使用内连接进行 SUM,但是它显示了每个单元格,而不是将它们加在一起并仅显示在一个单元格中,我哪里出错了?
I have been trying to do a SUM with inner join, however it shows each cell rather than adding them together and showing only in one cell, where am I going wrong?
SELECT SUM(trans) as 'Transactions',city as 'city'
FROM account
INNER JOIN branch
ON branch.bID
GROUP BY account.trans, branch.city;
推荐答案
使用以下查询将返回每个城市的总和
Use the following query which will return the sum per city
SELECT SUM(trans) as 'Transactions', branch.city as 'city'
FROM account
INNER JOIN branch
ON branch.bID = account.bID
GROUP BY branch.city;
这篇关于内连接求和 SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文