o*y
1 楼
这是一道面试题。
you have three tables: students(sid, sname), courses(cid,cname), enrollment(
sid,cid).
find the number of students who didn't take 'Math'.
One solution:
select count(distinct sid)
from student
when sid not in
(select sid
from enrollment E, courses C
where E.cid = C.cid
and C.cname = 'Math')
Now the question is to find another solution without subquery, only using
joins.
you have three tables: students(sid, sname), courses(cid,cname), enrollment(
sid,cid).
find the number of students who didn't take 'Math'.
One solution:
select count(distinct sid)
from student
when sid not in
(select sid
from enrollment E, courses C
where E.cid = C.cid
and C.cname = 'Math')
Now the question is to find another solution without subquery, only using
joins.