Example of EXCEPT Operator - SQL
Example, like its counterpart in the theory book, illustrates the convenience of allowing any table expression to be the source for an INSERT. It assumes that all the exam scripts submitted by students have been marked and it has been decided to record marks of zero for students who failed to turn up for an exam they should have sat. (Remember that SQL's EXCEPT requires its operands to be of the same degree, unlike NOT MATCHING-hence the third element, 0, of the second operand in the example.)
Example: Awarding zero marks to students who failed to take the exam
INSERT INTO EXAM_MARK
SELECT StudentId, CourseId, 0
FROM IS_ENROLLED_ON
EXCEPT
SELECT StudentId, CourseId, 0
FROM EXAM_MARK;