GATE CSE 2025 Session 2 Q54: SQL queries for names of students enrolled in course 1470
- Databases
- 2 marks
- MSQ
- No negative marking
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
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
Source: official GATE 2025 Session 2 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key
More Databases PYQs
- 2026 Session 1 · Q30Which functional dependency inferences always hold
- 2026 Session 1 · Q31Dependency-preserving decompositions for 1NF, 2NF, 3NF, BCNF
- 2026 Session 1 · Q43Relational algebra equivalent of a tuple calculus join query
- 2026 Session 1 · Q65Number of superkeys with candidate keys {A,B} and {A,C}
- 2026 Session 2 · Q15Match DBMS schema levels with what they describe
- 2026 Session 2 · Q20When two transactions do not conflict on a data item