GATE CS 2011 · SQL Queries

MCQ · 2 marks · Problem DBMS-SQL-0107

Database table by name Loan_Records is given below.\[\begin{array}{|l|l|r|} \hline \text{Borrower} & \text{Bank\_Manager} & \text{Loan\_Amount} \\ \hline \text{Ramesh} & \text{Sunderajan} & 10000.00 \\ \text{Suresh} & \text{Ramgopal} & 5000.00 \\ \text{Mahesh} & \text{Sunderajan} & 7000.00 \\ \hline \end{array}\]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
);
  1. A
    3
  2. B
    9
  3. C
    5
  4. D
    6

Solve it on GATE DA practice →More Relational Model & SQL problems

Show the worked solution\[\boxed{\text{natural join on Bank\_Manager: rows} = \sum_m n_S(m)\, n_T(m)}\]Sunderajan appears twice in S and twice in T: \(2 \times 2 = 4\) rows. Ramgopal appears once in each: \(1\) row.\(4 + 1 = 5\).Answer: C

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com