Hello SQL gurus:
In a class project of 20 sql questions, we were stopped at one of them. It
sounded very simple:"Find out the names of the department that does not
offer any 400 leverl courses", but yet we can't get the correct result in
one query. We know the correct result should be FIN and MKT department
since there is so little data so we can tell just by looking at it. But
our sql statement is not working out right. We can get the result of MKT
since it is not offering any course by using a left join, but FIN is
mixed. It offers 300 level course, no 400 level course, but other
department also offer 300 level courses. So how do we tell sql to work
this out, to exclude other departments that offer both 300 and 400 level
course(IS and MGT)? subquery or temp table? Is it possible to do it in one
query? Thank you everybody!
There are 2 tables:
Table 1: departments
DCODE DName FID
FIN Finance 035
IS Information Systems 029
MGT Management 047
MKT Marketing 087
Table2: courses
DCODE CourseNumber CourseTitle FID
FIN 380 Financial Analysis 035
IS 380 Database 047
IS 480 Advanced Database 087
IS 485 System Analysis 023
MGT 380 Human Resources 067
MGT 480 Management Concept 044
department.dcode= course.dcode
and department.fid = course.fid