List names of customers with more than 1 loan
select t1.cust_name from customer as t1 join loan as t2 on t1.cust_id = t2.cust_id group by t1.cust_name having count ( * ) > 1
How about those with only 1 loan?
select t1.cust_name from customer as t1 join loan as t2 on t1.cust_id = t2.cust_id group by t1.cust_name having count ( * ) = 1
How about those with no loans?
select t1.cust_name from customer as t1 join loan as t2 on t1.cust_id = t2.cust_id group by t1.cust_name having count ( * ) = 0
List the customers who have mortgages
select loan_id from loan where loan_type = 'Mortgages'
What is their name?
select t1.cust_name from customer as t1 join loan as t2 on t1.cust_id = t2.cust_id where loan_type = 'Mortgages'