Database table by name is given below.
What is the output of the following SQL query?
SELECT count(*) FROM ( SELECT Borrower, Bank_Manager FROM Loan_Records) AS S NATURAL JOIN (SELECT Bank_Manager, Loan_Amount FROM Loan_Records) AS T );
GATE CSE 2011Databases › SQLVerified
(C) 5 5 5
Compute the natural join on the common column $Bank_Manager$. For each bank manager value, every S-row with that manager joins with every T-row having the same manager, so the total count is the sum of squared frequencies of each $Bank_Manager$ value.
Natural join matches rows on $Bank_Manager$. The frequencies are Sunderajan: 2, Ramgopal: 1. Hence the join count is 2*2 + 1*1 = 5, matching option C.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.