Consider the table Accounts(branch_id, account_id, balance) that stores the balance of an account in a bank branch.
Question:
Consider the table Accounts(branch_id, account_id, balance) that stores the balance of an account in a bank branch. What does the following SQL statement compute and what does it return for the following instance of Accounts.
SELECT A.branch_id, count(*) FROM Accounts A WHERE A.branch_id IN (
SELECT A2.branch_id FROM Accounts A2 GROUP BY A2.branch_id HAVING count(*)3)
AND A.balance< ( SELECT avg(A3.balance)
1
FROM Accounts A3
WHERE A3.branch_id=A.branch_id) GROUP BY A.branch_id
Instance of Accounts for Question 2
Branch_id Account_id Balance
B1 A1 100K
B1 A2 200K
B1 A3 100K
B2 A4 300K
B2 A5 100K
B2 A6 200K
B3 A7 100K
B4 A8 100K
B4 A9 100K
B4 A10 100K
Engineering Economic Analysis
ISBN: 9780195168075
9th Edition
Authors: Donald Newnan, Ted Eschanbach, Jerome Lavelle