我有這兩個表格: 先決條件:(cid,pre-cid) (記錄:sid,cid,qtr,year,grade)。SQL:找到完成課程的學生prerequsite
我必須找到那些只使用NOT IN來滿足某個班級的先決條件的學生。我當前的查詢是:
select distinct sid
from record
where sid not in (
select s.sid
from record s,
prerequisite p
where p.cid = "CSE132X"
and s.cid <> p.precid
and s.grade < 2
);
但是,我的查詢返回已採取任何先決條件,而不是所有先決條件的學生。我很難弄清楚如何製作,以便檢查課程的所有先決條件。
採樣數據與預期的結果集一起將有助於澄清你實際上是試圖實現。 –