Find the names of customers who have at least one loan.
select distinct t1.cust_name from customer as t1 join loan as t2 on t1.cust_id = t2.cust_id
which of them have loans with a total amount of more than 5000?
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 sum(t2.amount) > 5000
also show their account balances.
select t1.cust_name, t1.acc_type from customer as t1 join loan as t2 on t1.cust_id = t2.cust_id group by t1.cust_name having sum(t2.amount) > 5000