Skip to content
Related Articles

Related Articles

ISRO | ISRO CS 2017 – May | Question 7
  • Last Updated : 20 Mar, 2018
GeeksforGeeks - Summer Carnival Banner

What is the output of the following SQL query?

select count(*) from ((select Employee, Department from Overtime_allowance) as S
natural join (select Department, OT_allowance from Overtime_allowance) as T);

(A) 16
(B) 4
(C) 8
(D) None of the above
(E) none


Answer: (B)

Explanation: (select Employee, Department from Overtime_allowance) as S
natural join (select Department, OT_allowance from Overtime_allowance) as T)

Table S                          Table R
Employee     Department          Department     OT_allowance
Rama         Mechanical          Mechanical     5000
Gopi         Electrical          Electrical     2000
Sindhu       Computer            Computer       4000
Mahesh       Civil               Civil          1500

Now when we apply a natural join on S and R, it matches the common attribute Department in both the tables and outputs the common tuples. So, 4 tuples will be given as the output.
Correct option (B)

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :