- Year not given
SQL: branch city with assets over 1000000
Short answer
Use SELECT branch_city, SUM(assets) FROM Branch WHERE assets > 1000000 GROUP BY branch_city. This sums assets per city for branches with assets over one million.
Consider database schema: Account (acc_no, branch_name, balance) Branch (branch_name, branch_city, assets) Customer (customer_name, customer_street, customer_city) Loan (loan_no, branch_name, amount) Depositor (customer_name, acc_no) Borrower (customer_name, loan_no) List branch city and total assets where asset > 1000000.
Branch city and assets are both in the Branch table. Since "total assets" is asked per city, group by city and use SUM; the assets > 1000000 condition is on individual branches, so it goes in WHERE.
SELECT branch_city, SUM(assets) AS total_assets
FROM Branch
WHERE assets > 1000000
GROUP BY branch_city;
Sample (tested): Branches Dharan (2000000) and Dh2 (3000000) are in Dharan city, Itahari (1500000) is in Itahari, and Pokhara (500000) is excluded. Output: (Dharan, 5000000), (Itahari, 1500000).
If the question only wants each branch listed with its own assets (no adding up), use:
SELECT branch_city, assets
FROM Branch
WHERE assets > 1000000;
To filter on the city total instead of each branch, the condition would move to HAVING SUM(assets) > 1000000.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- SQL: customer name and address · Database Management System, chapter 3
- SQL: branches with avg balance over 50000 · Database Management System, chapter 3
- SQL: number of accounts per branch · Database Management System, chapter 3
- SQL: customer names beginning with su · Database Management System, chapter 3
- SQL: customer, branch, account details · Database Management System, chapter 3
- SQL: customers with account in Dharan · Database Management System, chapter 3
- SQL: create tables for bank schema · Database Management System, chapter 3
- SQL: create and use bank database · Database Management System, chapter 3
- SQL: increase balances by 100% and 50% · Database Management System, chapter 3
- RA: increase loans over 10000 · Database Management System, chapter 3
- RA: count accounts in each branch · Database Management System, chapter 3
- RA: delete loans under 1000 · Database Management System, chapter 3