Professional Documents
Culture Documents
-- [A] Display Customer who borrowed loan from ‘Station’ branch of ‘Pune’ city.
SELECT CM.*
FROM Customer_Master CM
JOIN Cust_Branch_Loan CBL ON CM.Cust_No = CBL.Cust_No
JOIN Branch_Master BM ON CBL.Branch_Id = BM.Branch_Id
WHERE BM.Branch_Name = 'Station' AND BM.City = 'Pune';
-- [B] Display Customer who borrowed loan of maximum amount from ‘S.G.’ branch of
‘Baroda’ City.
SELECT CM.*
FROM Customer_Master CM
JOIN Cust_Branch_Loan CBL ON CM.Cust_No = CBL.Cust_No
JOIN Branch_Master BM ON CBL.Branch_Id = BM.Branch_Id
WHERE BM.Branch_Name = 'S.G.' AND BM.City = 'Baroda'
ORDER BY CBL.Loan_Amount DESC
FETCH FIRST 1 ROWS ONLY;
SELECT CM.*
FROM Customer_Master CM
LEFT JOIN Cust_Branch_Loan CBL ON CM.Cust_No = CBL.Cust_No
WHERE CBL.Cust_No IS NULL;
SELECT CM.*
FROM Customer_Master CM
JOIN Cust_Branch_Loan CBL ON CM.Cust_No = CBL.Cust_No
JOIN Loan_Master LM ON CBL.Loan_Id = LM.Loan_Id
WHERE LM.Loan_Type = 'Personal'
ORDER BY CBL.Loan_Amount ASC
FETCH FIRST 1 ROWS ONLY;