GATE CS 2012 · SQL Queries

MCQ · 2 marks · Problem DBMS-SQL-0104

Consider the following relations A, B and C:\[\begin{array}{ccc} \textbf{A} & \textbf{B} & \textbf{C} \\ \begin{array}{|c|c|c|} \hline \text{Id} & \text{Name} & \text{Age} \\ \hline 12 & \text{Arun} & 60 \\ 15 & \text{Shreya} & 24 \\ 99 & \text{Rohit} & 11 \\ \hline \end{array} & \begin{array}{|c|c|c|} \hline \text{Id} & \text{Name} & \text{Age} \\ \hline 15 & \text{Shreya} & 24 \\ 25 & \text{Hari} & 40 \\ 98 & \text{Rohit} & 20 \\ 99 & \text{Rohit} & 11 \\ \hline \end{array} & \begin{array}{|c|c|c|} \hline \text{Id} & \text{Phone} & \text{Area} \\ \hline 10 & 2200 & 02 \\ 99 & 2100 & 01 \\ \hline \end{array} \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. A
    4
  2. B
    3
  3. C
    0
  4. D
    1

Solve it on GATE DA practice →More Relational Model & SQL problems

Show the worked solution\[\boxed{x > \text{ALL}(\varnothing) \text{ is true for every } x}\]B has no tuple with Name = 'Arun', so the subquery returns an empty set and the condition holds for every row of A.All \(3\) tuples of A are returned.Answer: B

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com