---
title: "SQL: customers with account in Dharan"
subject: "Database Management System"
chapter: 3
key: "semester_6/database_management_system:sql-customers-dharan-branch"
source: https://www.bctengineer.com/q/semester_6/database_management_system/sql-customers-dharan-branch
site: BCT Engineering
---

# SQL: customers with account in Dharan

Database Management System · Chapter 3: Relational Languages & Relational Model

- Asked in: year not given
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/database_management_system/sql-customers-dharan-branch
- Whole chapter: https://www.bctengineer.com/md/semester_6/database_management_system/chapter-3

## Question

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 the name of customers who have acc in dharan branch.

## Short answer

Join Depositor and Account on acc_no, filter branch_name = 'Dharan', and select DISTINCT customer_name to avoid repeats. For example: SELECT DISTINCT d.customer_name FROM Depositor d JOIN Account a ON d.acc_no = a.acc_no WHERE a.branch_name = 'Dharan'.

## Answer

The customer's name is in `Depositor`, the branch is in `Account`, and the two are linked by `acc_no`. So we join `Depositor` and `Account` and filter on the branch name. `DISTINCT` removes repeats when a customer has more than one account in the branch.

**Using a join**

```sql
SELECT DISTINCT d.customer_name
FROM   Depositor d
JOIN   Account   a ON d.acc_no = a.acc_no
WHERE  a.branch_name = 'Dharan';
```

**Using a subquery**

```sql
SELECT DISTINCT customer_name
FROM   Depositor
WHERE  acc_no IN (SELECT acc_no
                  FROM   Account
                  WHERE  branch_name = 'Dharan');
```

**Relational algebra**

Π customer_name (σ branch_name = 'Dharan' (Depositor ⋈ Account))

**Sample (tested):** Sujan holds accounts 1 and 2, both in Dharan, so the output is just `Sujan` once.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which tables are joined?
   A. Customer and Branch
   B. Depositor and Account on acc_no
   C. Loan and Borrower
   D. Branch only
   Answer: B. Name in Depositor, branch in Account. (Key point: Join tables)

2. Why DISTINCT?
   A. Faster
   B. Required
   C. To sort
   D. A customer may have several accounts in the branch
   Answer: D. Removes repeats. (Key point: DISTINCT)

3. Which is an equivalent form?
   A. customer_name IN Account
   B. Subquery: acc_no IN (SELECT acc_no FROM Account WHERE branch_name='Dharan')
   C. JOIN Loan
   D. GROUP BY only
   Answer: B. Subquery gives the same result. (Key point: Alternative)

## Close variants set in other exams

- [SQL: customer name and address](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-customer-name-address) — Database Management System, chapter 3
- [SQL: number of accounts per branch](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-count-accounts-branch) — Database Management System, chapter 3
- [SQL: customer names beginning with su](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-customer-name-like-su) — Database Management System, chapter 3
- [SQL: branch city with assets over 1000000](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-branch-assets-million) — Database Management System, chapter 3

## Related in Database Management System

- [SQL: customer, branch, account details](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-natural-join-details) — Database Management System, chapter 3
- [SQL: create tables for bank schema](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-create-tables-bank) — Database Management System, chapter 3
- [SQL: create and use bank database](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-create-database-bank) — Database Management System, chapter 3
- [SQL: branches with avg balance over 50000](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-avg-balance-branch) — Database Management System, chapter 3
- [SQL: increase balances by 100% and 50%](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Asql-update-balance-rates) — Database Management System, chapter 3
- [RA: count accounts in each branch](https://www.bctengineer.com/question.md?key=semester_6%2Fdatabase_management_system%3Ara-count-accounts-branch) — Database Management System, chapter 3
