我在Access中有两个表:
BANK(B_ID,B_NAME)
帐户(A_ID,A_SUM,ID_B)
我要做的就是比较所有银行并进行查询,这将向我显示哪个银行(或多个银行)拥有的账户多于特定银行的银行A"银行A"。
我只是SQL的初学者。我已尝试使用GROUP BY和HAVING以及SUM进行各种查询,但我似乎无法将它们弄好。求你帮忙吗?
答案 0 :(得分:1)
select banks.b_name
from (
select count(*) as total_accounts , b_name from bank b inner
join account a on b.b_id = a.id_b
) as banks
where banks.total_accounts > ( select count(*)
from bank
inner join
account
on bank.b_id = account.id_b
where bank.b_name = 'BankA'
)