List the names of all different customers who have an loan.
select distinct t1.cust_name from customer as t1 join loan as t2 on t1.cust_id = t2.cust_id
For each customer, what is their total amount of loans?
select t1.cust_name, sum(t2.amount) from customer as t1 join loan as t2 on t1.cust_id = t2.cust_id group by t1.cust_name
sort the result by the total amount, and no need to show the total amount.
select t1.cust_name from customer as t1 join loan as t2 on t1.cust_id = t2.cust_id group by t1.cust_name order by sum(t2.amount)