The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+2 votes

Consider the following three SQL queries (Assume the data in the people table):

  1. Select Name from people where Age>21;
  2. Select Name from people where Height>180;
  3. Select Name from people where (Age>21) or (Height>180);

If the SQL queries a and b above, return 10 rows and 7 rows in the result set respectively, then what is one possible number of rows returned by the SQL query c?

  1. 3
  2. 7
  3. 10
  4. 21
in Databases by Veteran (103k points)
retagged by | 1.3k views

2 Answers

+3 votes
When set a and set b all rows are distinct ans would be = 10+7 = 17

When set b is subset of set a than

10+7-7 = 10

Only these two options are preferable...
by Boss (25.4k points)
answer can be 17 also but since 10 is given only so choose 10 rt?
Ans should be between 10 to 17 both inclusive
if and  replace OR then 0-7
0 votes

Option C

 Name from people where Age>21=10

 Name from people where Height>180=7

then those who have Age>21 and Height>180 will be (intersection) =7 names, which are included in query(a) output=10, then remaining names out of 10 will be 3 names that does not satisfy both condition but first condition.

therefore 7+3=10


by (457 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,362 questions
55,786 answers
90,919 users