问题很简单,使用一个函数即可解决问题,具体SQL如下:
select cust_id,cust_name,loan_bank,loan from (
select a.cust_id,
a.cust_name,
b.loan_bank,
b.loan_num as loan,
row_number() over(partition by b.cust_id order by b.loan_num desc) as num
from cust_info a, cust_loan_info b
where a.cust_id = b.cust_id)
where num = 1