GATE Assistant

Past questions › Computer Science and Information Technology › GATE 2025 set2

GATE 2025 set2 · CS · MSQ · 2 marks · Databases › SQL

GATE 2025 set2 Computer Science and Information Technology question: Consider the following relational schema: Students (<u rollno: integer</u , name:…

Consider the following relational schema:

Students (<u>rollno: integer</u>, name: string, age: integer, cgpa: real)

Courses (<u>courseno: integer</u>, cname: string, credits: integer)

Enrolled (<u>rollno: integer</u>, <u>courseno: integer</u>, 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;
    
Show answer

Official answer: A,C,D

Practise this question with exam-style marking

Discussion

No discussion yet.

Join the discussion