从不同的表中计算特定值的行两个表都包含一个相同的列?

时间:2017-11-04 16:25:47

标签: mysql sql database

Account(Acc_no, branch_name,balance)
Depositor(cust_name,Acc_no)

找不到。每个分支机构的存款人?

2 个答案:

答案 0 :(得分:0)

SELECT A.branch_name, COUNT(D.cust_name) FROM Account A INNER JOIN Depositor D GROUP BY A.branch_name

希望这有帮助

答案 1 :(得分:0)

选择ACCOUNT.BRANCH_NAME,COUNT(DEPOSITOR.CUST_NAME)来自ACCOUNT INNER JOIN存款人帐户.ACC_NO = DEPOSITOR.ACC_NO GROUP BY BRANCH_NAME;