GateAI
SQL

GATE CSE 2012 · Q51

MCQ2 marksMedium

Time

Common Data for Questions 50 and 51

Consider the following relations AA, BB and CC: 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')

GATE CSE 2012 Q51 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) 3

SQL
  1. Evaluate the subquery: ```sql SELECT B.Age FROM B WHERE B.Name = 'Arun' ``` Looking at relation BB, the distinct values of Name are 'Shreya', 'Hari', and 'Rohit'. There is no tuple with Name = 'Arun'. Therefore, the subquery produces an empty set (∅)(\emptyset).

  2. Evaluate the > ALL condition: In SQL, comparison with > ALL (empty set) evaluates to TRUE for every value (vacuously true, because there exists no element in the subquery result that violates the condition).

  3. Evaluate the outer query: Since the WHERE clause evaluates to TRUE for every tuple in relation AA, all tuples of AA are returned. Relation AA contains 33 tuples:

    • (12,Arun,60)(12, \text{Arun}, 60)

    • (15,Shreya,24)(15, \text{Shreya}, 24)

    • (99,Rohit,11)(99, \text{Rohit}, 11)

Thus, the query returns 3 tuples.

Hence, the correct option is (B).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This SQL previous year question is Q51 of the GATE CSE 2012 paper. Find more GATE CSE PYQs on SQL in Databases, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related SQL PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

SQL in GATE CSE

SQL has 17 GATE CSE PYQs across 14 papers from 2011 to 2025. 5 of them are 2-mark MCQs like this one, and GATE CSE 2012 has 2.

How GATE tests SQL

More from GATE CSE 2012

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2012 · Q51 · MCQ

Common Data for Questions 50 and 51: Consider the following relations A, B and C: 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')

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.