edited by
6,221 views
9 votes
9 votes

$\begin{array}{|l|l|l|l|l|} \hline \textbf{Employee} & \textbf{Department} & \textbf{OT_allowance} \\ \hline \text{RAMA} & \text{Mechanical} & \text{5000} \\\hline \text{GOPI} & \text{Electrical} & \text{2000} \\\hline \text{SINDHU} & \text{Computer} & \text{4000} \\\hline \text{MAHESH} & \text{Civil} & \text{1500} \\\hline  \end{array}$

What is the output of the following SQL query?

select count(*) from 
    ((select Employee, Department from Overtime_allowance) 
    natural join 
    (select Department, OT_allowance from Overtime_allowance) 
    as T);
  1. $16$
  2. $4$
  3. $8$
  4. None of the above
edited by

2 Answers

Best answer
26 votes
26 votes

I think option B will be correct...

selected by
0 votes
0 votes

When elements are separated by a comma in SELECT, then it's just different elements.

When elements are separated by a comma in FROM, then it's the cross product of elements, and by "elements", here we mean relations.

Employee

Department

 

RAMA

Mechanical

 

GOPI

Electrical

 

SINDHU

Computer

 

MAHESH

Civil

 

 

Department

OT_allowance

 

Mechanical

5000

 

Electrical

2000

 

Computer

4000

 

Civil

1500

 

4 unique values from Table 1 matches with that of table 2 under the common attribute name Department

So, Option B

edited by
Answer:

Related questions

7 votes
7 votes
2 answers
1
sh!va asked May 7, 2017
4,544 views
Which of these is characteristic of $\textsf{RAID 5}?$Dedicated parityDouble parityHamming code parityDistributed parity
11 votes
11 votes
3 answers
2
sh!va asked May 7, 2017
4,715 views
ACID properties of a transactions areAtomicity, consistency, isolation, databaseAtomicity, consistency, isolation, durabilityAtomicity, consistency, integrity, durability...
6 votes
6 votes
3 answers
3
sh!va asked May 7, 2017
9,138 views
Which symbol denote derived attributes in ER Model?Double ellipseDashed ellipseSquared ellipseEllipse with attribute name underlined
7 votes
7 votes
3 answers
4
sh!va asked May 7, 2017
10,346 views
What does a data dictionary will identify?Field nameField formatField typesAll of the above