GATE DA 2025 | Question 33
On a relation named Loan of a bank:
| loan_number | branch_name | amount |
|---|---|---|
| L11 | Banjara Hills | 90000 |
| L14 | Kondapur | 50000 |
| L15 | SR Nagar | 40000 |
| L22 | SR Nagar | 25000 |
| L23 | Balanagar | 80000 |
| L25 | Kondapur | 70000 |
| L19 | SR Nagar | 65000 |
the following SQL query is executed.
SELECT L1.loan_number
FROM Loan L1
WHERE L1.amount > (SELECT MAX (L2.amount)
FROM Loan L2
WHERE L2.branch_name = 'SR Nagar');The number of rows returned by the query is __________ (Answer in integer)
Explanation
Answer: 3
The inner query does not use L1, so it produces a single value: the largest SR Nagar amount, \(\max(40000, 25000, 65000) = 65000\).
The outer query keeps the loans whose amount is strictly greater than 65000: L11 (90000), L23 (80000) and L25 (70000). L19 is left out because 65000 is not greater than itself, and every other loan is smaller. So the query returns 3 rows.
Answer: 3