ID_Number|Subject_Code|Grade
000001 |Math |Dropped
000001 |English |Passed
000001 |Physics |Passed
000002 |Math |Passed
000002 |English |Passed
000002 |Physics |Passed
000003 |Math |Passed
000003 |English |Passed
000003 |Physics |Passed
现在我希望SELECT DISTINCT ID_Number
其中所有subject_code的等级都应为Passed,查询应返回000002和000003,因为000001有1个Dropped主题,其他等级不包括'Withdrawn'和'Failed ”。
答案 0 :(得分:3)
SELECT DISTINCT ID_Number
FROM <table>
WHERE ID_Number not in(select ID_Number from <table> where Grade <> 'Passed')