David L. answered 05/10/23
SQL expert, fantastic teacher, complete courses or help with 1 query
Often, more than one query gives you the same results. Here's one way to do it:
The innermost subquery gives you all the class_id's in the Student table.
The middle query finds the subject_id of all empty classes, which have no students. The class_id of empty classes will not appear in the list of class_id's returned by the innermost subquery.
The outermost query gets the list of subject_id's with empty classes from the middle query, and gets the subject_name's and subject_id's of those classes.