• edited by
23,393 views
69 69 votes

Consider the following relations $A, B$ and $C:$
 

$$\overset{\textbf{A}}{\begin{array}{|c|c|c|}\hline\\
\textbf{Id}&    \textbf{Name}&  \textbf{Age} \\\hline
12&     \text{Arun}&    60 \\ \hline   
15&     \text{Shreya}& 24 \\     \hline
99&     \text{Rohit}&  11    \\\hline
\end{array}}\qquad \overset{\textbf{B}}{\begin{array}{|c|c|c|}\hline\\
\textbf{Id}&    \textbf{Name}&  \textbf{Age} \\\hline
15&     \text{Shreya}& 24 \\     \hline 25 & \text{Hari} & 40 \\ \hline 98 & \text{Rohit} & 20 \\ \hline
99&     \text{Rohit}&  11    \\\hline
\end{array}}\qquad \overset{\textbf{C}}{\begin{array}{|c|c|c|}\hline\\
\textbf{Id}&    \textbf{Phone}&  \textbf{Area} \\\hline
10&     2200&    02 \\ \hline   
99&     2100& 01\\     \hline
\end{array}}$$

How many tuples does the result of the following SQL query contain?

SELECT A.Id 
FROM A 
WHERE A.Age > ALL (SELECT B.Age 
                    FROM B 
                    WHERE B.Name = ‘Arun’)
  1. $4$
  2. $3$
  3. $0$
  4. $1$

5 Answers

Best answer
86 86 votes

<cond> ALL evaluates to TRUE if inner query returns no tuples. So, Number of tuples returned will be number of tuples in $A = 3$.

Reference: http://dcx.sap.com/1200/en/dbusage/all-test-quantified-subquery.html

Correct Answer: $B$

• edited by
16 16 votes
Ans 3 tuple

All condition with empty return true

Also the result of subquery is empty So all id of A will be selected.
• edited by
10 10 votes

ALL(empty)==> TRUE

When the set is empty then there is no element which returns false on condition, since there is not a single element that returns false, FOR ALL is TRUE

ANY(empty) ==>FALSE

Any means there exists some element in the set such that our condition will hold, since there is no element in the set we can’t say our condition will hold. So  it returns false.

• edited by
2 2 votes

Answer (B)
The meaning of “ALL” is the A.Age should be greater than all the values returned by the subquery. There is no entry with name “arun” in table B. So the subquery will return NULL. If a subquery returns NULL, then the condition becomes true for all rows of A (See this for details). So all rows of table A are selected.

Answer:
Position:
Show:

Related questions

91 91 votes
8 answers 8 answers
57.6k
57.6k views
gatecse asked Aug 5, 2014
57,643 views
Which of the following statements are TRUE about an SQL query?P : An SQL query can contain a HAVING clause even if it does not have a GROUP BY clauseQ : An SQL query can ...
108 108 votes
9 answers 9 answers
46.0k
46.0k views
gatecse asked Sep 29, 2014
45,967 views
Consider the following relations $A, B$ and $C:$$$\overset{\text{A}}{\begin{array}{|c|c|c|} \hline \text {ID} & \text {Name} & \text {Age} \\\hline\text{12}& \text{Arun}...
66 66 votes
4 answers 4 answers
20.4k
20.4k views
Arjun asked Sep 29, 2014
20,427 views
Suppose $R_{1} (\underline{A}, B)$ and $R_{2} (\underline{C}, D) $ are two relation schemas. Let $r_{1}$ and $r_{2}$ be the corresponding relation instances. $B$ is a for...
106 106 votes
10 answers 10 answers
37.2k
37.2k views
Arjun asked Sep 25, 2014
37,205 views
Consider the following transactions with data items $P$ and $Q$ initialized to zero:$${\begin{array}{|c|l|r|c|}\hline \textbf{$T_1$}& \text{read (P);}\\ & \text{read...