Question:

Consider the relational database with the following four schemas and their respective instances: \[ \text{Student(sNo, sName, dNo)} \text{       }\text{Dept(dNo, dName)} \\ \text{Course(cNo, cName, dNo)} \text{         } \text{Register(sNo, cNo)} \] 

SQL Query: 

SELECT * FROM Student AS S WHERE NOT EXIST
 (SELECT cNo FROM Course WHERE dNo = “D01”
	EXCEPT 
 SELECT cNo FROM Register WHERE sNo = S.sNo) 

The number of rows returned by the above SQL query is___________.

Show Hint

In SQL, using the EXCEPT clause allows you to exclude certain rows from the results. Here, the query excludes courses that are already registered by the students.
Updated On: Jan 11, 2026
Hide Solution
collegedunia
Verified By Collegedunia

Correct Answer: 2

Solution and Explanation

SQL Query: \[ \text{SELECT FROM Student AS S WHERE NOT EXIST} \] \[ \left( \text{SELECT cNo FROM Course WHERE dNo = "D01"} \right) \] \[ \text{EXCEPT SELECT cNo FROM Register WHERE sNo = S.sNo} \] The number of rows returned by the above SQL query is: \[ \boxed{2}. \]

Was this answer helpful?
0
0