GATE CS 2022 | Question 56
Databases › SQL Queries · NAT · 2 marks · Answer: 2
- Question 56Databasesnat2 marksSchemas: Student(sNo,sName,dNo), Dept(dNo,dName), Course(cNo,cName,dNo), Register(sNo,cNo). The query
SELECT * FROM Student AS S WHERE NOT EXISTS (SELECT cNo FROM Course WHERE dNo='D01' EXCEPT SELECT cNo FROM Register WHERE sNo=S.sNo)returns __________ rows (students registered for every D01 course).Answer: 2
Solution
Answer: 2 The query uses the "NOT EXISTS ... EXCEPT" pattern to find students who are registered for every course offered by department D01 (relational division). Evaluating against the given instance, exactly 2 students satisfy this, so 2 rows are returned.
More GATE PYQ on SQL Queries
All GATE CS Databases PYQ →Attempt GATE CS 2022 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →