Skip to content
GATEiit

GATE CSE 2025 Session 2 Q54: SQL queries for names of students enrolled in course 1470

Question

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?

-- (A)
SELECT S.name
FROM Students S
WHERE EXISTS (SELECT * FROM Enrolled E
              WHERE E.courseno = 1470
                    AND E.rollno = S.rollno);

-- (B)
SELECT S.name
FROM Students S
WHERE SIZEOF (SELECT * FROM Enrolled E
              WHERE E.courseno = 1470
                    AND E.rollno = S.rollno) > 0;

-- (C)
SELECT S.name
FROM Students S
WHERE 0 < (SELECT COUNT(*)
           FROM Enrolled E
           WHERE E.courseno = 1470
                 AND E.rollno = S.rollno);

-- (D)
SELECT S.name
FROM Students S NATURAL JOIN Enrolled E
WHERE E.courseno = 1470;

Try it: multiple select: one or more correct options

Select one or more options
Select all correct options. No negative marking, no partial marks.
Show answer and explanation

Answer: A, C, D (official GATE 2025 final answer key)

Concept used: Correlated subqueries with EXISTS or COUNT, and natural join on the common attribute rollno.

First step: Check each query is valid SQL first: SIZEOF is not an SQL function; then check the common attributes used by the natural join.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2025 Session 2 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key