This set of RDBMS Multiple Choice Questions & Answers (MCQs) focuses on “Sql Queries – IV”.
1. Find all the customers who have both a loan and an account at the Perryridge branch
View Answer
where branch_name = ‘Perryridge’ and
customer_name in
(select customer_name from account natural join depositor
where branch_name = ‘Perryridge’);
2. Find all customers who do have a loan at the bank, but do not have an account at the bank.
View Answer
where customer_name not in
(select customer_name from account natural join depositor);
3. Select the names of customers who have a loan at the bank, and whose names are neither Smith nor Jones
View Answer
where branch_name = ‘Perryridge’ and customer_name not in
(‘Smith’, ‘Jones’);
4. Find the names of all branches that have assets greater than those of at least one branch located in Brooklyn.
View Answer
assets > some(select assets from branch
where branch_city = ‘Brooklyn’);
5. Find the names of all branches that have an asset value greater than that of each branch in Brooklyn.
View Answer
assets > some(select assets from branch
where branch_city = ‘Brooklyn’);
6. Find all customers who have both an account and a loan at the bank
View Answer
where exists (select customer_name from depositor as b2
where b1.customer_name = b2.customer_name);
7. Find all customers who have an account at all the branches located in Brooklyn.
View Answer
account as b1 natural join depositor
where exists (select * from branch
where b1.branch_name = ‘Downtown’
and b1.branch_name=’Brighton’);
8. Find all customers who have at most one account at the Perryridge branch
View Answer
where branch_name = ‘Perryridge’ group by customer_name
having count(account_number)<=1;
9. Find all customers who have at least two accounts at the perryridge branch
View Answer
where branch_name = ‘Perryridge’ group by customer_name
having count(account_number)>=2;
Complex queries
10. Find the average account balance of those branches where the account balance is greater than Rs. 1200.
View Answer
where balance > 1200 group by branch_name;
Sanfoundry Global Education & Learning Series – RDBMS.
To practice all areas of RDBMS, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Apply for Computer Science Internship
- Check RDBMS Books
- Practice Computer Science MCQs
- Check Computer Science Books