GateAI
SQL

GATE CSE 2025 Set 2 · Q54

MSQ2 marksMedium

Time

Consider the following relational schema: Students (rollno: integer‾\underline{\text{rollno: integer}}, name: string, age: integer, cgpa: real) Courses (courseno: integer‾\underline{\text{courseno: integer}}, cname: string, credits: integer) Enrolled (rollno: integer‾\underline{\text{rollno: integer}}, courseno: integer‾\underline{\text{courseno: integer}}, grade: string) Which of the following options is/are correct SQL query/queries to retrieve the names of the students enrolled in course number (i.e., courseno) 1470?

Select all that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official answer: A) SELECT S.name FROM Students S WHERE EXISTS (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno);; C) SELECT S.name FROM Students S WHERE 0; D) SELECT S.name FROM Students S NATURAL JOIN Enrolled E WHERE E.courseno = 1470;

SQL

To retrieve the names of students enrolled in courseno = 1470:

  1. Option (A) uses a correlated subquery with the EXISTS predicate. For each student tuple in Students, it checks whether there exists at least one record in Enrolled with the matching rollno and courseno = 1470. If true, S.name is selected. This is valid and correct.

  2. Option (B) uses SIZEOF, which is not a standard SQL keyword or aggregate function for computing the cardinality of a subquery result. Thus, this query is syntactically invalid.

  3. Option (C) uses a scalar subquery SELECT COUNT(*) FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno. The condition 0 < (SELECT COUNT(*) ...) correctly evaluates to true whenever the student has at least one enrollment record in course 1470. This is valid and correct.

  4. Option (D) performs a NATURAL JOIN between Students and Enrolled. Since the only common attribute with the same name and type between the two tables is rollno, the join automatically equates Students.rollno = Enrolled.rollno. The WHERE clause then filters for E.courseno = 1470 and projects S.name. This is valid and correct.

Therefore, the correct options are A, C, and D.

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 Q54 of the GATE CSE 2025 Set 2 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. This is the only 2-mark MSQ among them, and it is the only one in GATE CSE 2025 Set 2.

How GATE tests SQL

More from GATE CSE 2025 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2025 Set 2 · Q54 · MSQ

Consider the following relational schema: Students ( rollno: integer, name: string, age: integer, cgpa: real) Courses ( courseno: integer, cname: string, credits: integer) Enrolled ( rollno: integer, courseno: integer, grade: string) Which of the following options is/are correct SQL query/queries to retrieve the names of the students enrolled in course number (i.e., courseno) 1470?

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.