Consider the following three SQL queries (Assume the data in the people table) :
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 (1) and (2) above, return 10 row and 7 rows in the result set respectively, then what is one possible number of rows returned by the SQL query (3)?
Show answerHide answer
Correct answer: (C) 10
Explanation
Query (3) returns the union of the two result sets, so it returns between 10 and 17 rows. If all rows are distinct the answer would be 10 + 7 = 17; if set (2) is a subset of set (1), it is 10 + 7 – 7 = 10. Among the options only 10 is possible.