Q.Assume that you are the Manager of the Loans department of a Finance House. To keep track of the loans you have created two tables : CUSTOMERS and LOANS. The sample data in these tables is given below : Table : CUSTOMERS C_ID C_Name Phone 00001 Raj Malhotra 1234567890 00003 David Xavier 3456789012 00004 Damini Iyer 3156789012 00008 Abdul 2345678901 Table : LOANS SNo C_ID L_Amt L_Date Terms RoI 1 00003 200000 2025-12-06 60 7.80 2 00008 2500000 2023-08-09 60 9.00 3 00001 500000 2025-08-13 48 6.00 4 00003 300000 2026-12-07 36 8.00 5 00004 600000 2026-12-07 60 6.00 Note : The tables may contain more records than shown here. The management of the Finance House needs certain reports from you. Write the queries to extract the following data to create the reports :
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Part (a): reports (i) COUNT RoI>7.0=3, (ii) join for names with L_Amt>1000000 (Abdul), (iii) join for C_ID/C_Name/Terms with L_Date>'2024-12-31', (iv)(a) all loans ORDER BY RoI DESC. Part (b): the (iv) alternative — C_ID and AVG(Terms) grouped by C_ID.
Two tables: CUSTOMERS(C_ID, C_Name, Phone) and LOANS(SNo, C_ID, L_Amt, L_Date, Terms, RoI). Reports (i), (ii) and (iii) are the same for both choices; task (iv) is where option (a) and option (b) differ.
Part (a)
(i) Count rows, not list them, so use COUNT(*). RoI values 7.80, 9.00 and 8.00 exceed 7.0.
SELECT COUNT(*) FROM LOANS WHERE RoI > 7.0;
Expected output:
3
(ii) The name lives in CUSTOMERS, the amount in LOANS, so join on C_ID. Only loan 2500000 (C_ID 00008) exceeds 1000000.
SELECT DISTINCT C.C_Name
FROM CUSTOMERS C JOIN LOANS L ON C.C_ID = L.C_ID
WHERE L.L_Amt > 1000000;
Expected output:
Abdul
(iii) Join again and filter dates after 31-Dec-2024 (i.e. 2025 onward).
SELECT C.C_ID, C.C_Name, L.Terms
FROM CUSTOMERS C JOIN LOANS L ON C.C_ID = L.C_ID
WHERE L.L_Date > '2024-12-31';
Expected output:
00003 David Xavier 60
00001 Raj Malhotra 48
00003 David Xavier 36
00004 Damini Iyer 60
(iv)(a) "Details" = all columns of LOANS, sorted highest interest first.
SELECT * FROM LOANS ORDER BY RoI DESC;
``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.