使用内部联接时如何计算结果

用户名

我在下面有一个简单的查询,该查询基本上可以过滤每个分支的储蓄帐户。

SELECT Account.bID as Branch,branch.bAddress.street as Street, branch.bAddress.city as City, branch.bAddress.postcode as Postcode, Account.accType as Type
FROM Account
INNER JOIN branch
ON Account.bID=branch.bID where accType='savings';

我正在尝试添加一个计数,因此它不是显示列表,而是显示每个分支的储蓄账户金额。我不太确定我要在何处添加此特定查询的计数。

任何帮助表示赞赏。

瓦姆西·普拉巴拉(Vamsi Prabhala)
SELECT branch.bid, branch.bAddress.street as Street, 
branch.bAddress.city as City, branch.bAddress.postcode as Postcode,   
count(account.*) as savings_count
FROM Account
INNER JOIN branch
ON Account.bID=branch.bID where accType='savings'
group by branch.bid, branch.bAddress.street, 
branch.bAddress.city, branch.bAddress.postcode;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章