GATE CS 2025 · Set-2 · SQL Queries

MSQ · 2 marks · Problem DBMS-SQL-0048

Consider the following relational schema:\(\text{Students}(\underline{\text{rollno: integer,}}\text{ name: string, age: integer, cgpa: real})\)\(\text{Courses}(\underline{\text{courseno: integer,}}\text{ cname: string, credits: integer})\)\(\text{Enrolled}(\underline{\text{rollno: integer,}}\ \underline{\text{courseno: integer,}}\text{ 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?
  1. A
    SELECT S.name FROM Students S WHERE EXISTS (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno)
  2. B
    SELECT S.name FROM Students S WHERE SIZEOF (SELECT * FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno) > 0
  3. C
    SELECT S.name FROM Students S WHERE 0 < (SELECT COUNT(*) FROM Enrolled E WHERE E.courseno = 1470 AND E.rollno = S.rollno)
  4. D
    SELECT S.name FROM Students S NATURAL JOIN Enrolled E WHERE E.courseno = 1470

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

Show the worked solutionOfficial GATE Answer Key: A, C, D.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/460849/gate-cse-2025-set-2-question-44

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