Redirected
in Databases edited by
4,940 views
2 votes
2 votes

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

  1. Select Name from people where $\text{Age}>21$;
  2. Select Name from people where $\text{Height}>180$;
  3. Select Name from people where $(\text{Age}>21)$ or $(\text{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 edited by
4.9k views

1 comment

suppose there are 7 people whose height > 180 but there age is <21(select based on height)

and there are 10 people whose age>21 but there height is <180(select based on age)

so we will get 10+7 =17 rows


If 7 people have height >180 and age>21

and 3 people have height<180 and age>21

then we will get 7+3 = 10 rows

so range of rows that we will get would be between 10 to 17.

3
3

3 Answers

3 votes
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...

3 Comments

answer can be 17 also but since 10 is given only so choose 10 rt?
0
0
Ans should be between 10 to 17 both inclusive
1
1
if and  replace OR then 0-7
0
0
0 votes
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

 

0 votes
0 votes

Maximum We Get 17 Row

Suppose there are 7 people whose height > 180 but there age is <21(select based on height)

and there are 10 people whose age>21 but there height is <180(select based on age)

so we will get 10+7 =17 rows

 

 

Minimum We Get 10 Row

If 7 people have height >180 and age>21

and 3 people have height<180 and age>21

then we will get 7+3 = 10 rows

 

Answer:

Related questions