Test Index
CBSE Class 12 Computer Science 2026 Paper Set 4
© examsnet.com
Question : 34 of 37
Marks:
+1,
-0
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
Table: LOANS
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 :(i) Number of records from LOANS table where Rate of Interest (RoI) is above 7.0.(ii) Names of the customers whose loan amount (L_Amt) is above 1000000.(iii) C_ID, C_Name and Terms of all those records where Loan Date (L_Date) is after 31st December, 2024.(iv) (a) Details of all the loans in the descending order of RoI.OR(b) C_ID and average term for each C_ID from the LOANS table.
| C_ID | C_Name | Phone |
|---|---|---|
| 00001 | Raj Malhotra | 1234567890 |
| 00003 | David Xavier | 3456789012 |
| 00004 | Damini Iyer | 3156789012 |
| 00008 | Abdul | 2345678901 |
| 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 |
Solution:
Concept: C_Name is in CUSTOMERS while L_Amt, L_Date and Terms are in LOANS, so parts (ii) and (iii) join the two tables on the common column C_ID (equi-join).(i)
SELECT COUNT(*) FROM LOANSWHERE RoI > 7.0;For the sample data this gives 3 (RoI 7.80, 9.00, 8.00).(ii)
SELECT C_NameFROM CUSTOMERS, LOANSWHERE CUSTOMERS.C_ID = LOANS.C_ID AND L_Amt > 1000000;For the sample data this gives Abdul (loan of 2500000).(iii)
SELECT CUSTOMERS.C_ID, C_Name, TermsFROM CUSTOMERS, LOANSWHERE CUSTOMERS.C_ID = LOANS.C_ID AND L_Date > '2024-12-31';C_ID is in both tables, so it must be qualified with a table name. Dates in 'YYYY-MM-DD' form compare correctly. For the sample data this lists loans 1, 3, 4 and 5 (00003 David Xavier 60, 00001 Raj Malhotra 48, 00003 David Xavier 36, 00004 Damini Iyer 60).(iv)(a)
SELECT * FROM LOANSORDER BY RoI DESC;OR (iv)(b)
SELECT C_ID, AVG(Terms) FROM LOANSGROUP BY C_ID;GROUP BY C_ID makes one group per customer and AVG(Terms) averages the terms in each group (for 00003: (60 + 36) / 2 = 48).
© examsnet.com
Go to Question: