I have the following table and I want to retrieve students (STUD_ID) who have taken either ENGLISH or SCIENCE. If they have taken both ENGLISH and SCIENCE, then do not retrieve.
So the desired output is 101,102,104,106,107
The table is actually a View with the first 2 columns from the table STUD_INFO and the subject column are from a Nested table within the STUD_INFO table.
SELECT groupid,
Stud_id,
NST.Name
FROM STUD_INFO,
TABLE(SUBINFO) NST
Can anyone help me with a SQL query? The interesting part is when I use
Subject = ENGLISH and Subject = Science it does not retrieve any data.
groupid Stud_id Subject
------- ------- --------
1 101 ENGLISH
1 102 MATH
1 103 ENGLISH
1 103 SCIENCE
1 104 ENGLISH
1 104 MATH
1 105 PT
1 105 ENGLISH
1 105 SCIENCE
2 106 ENGLISH
2 107 SCIENCE
2 108 SCIENCE
2 108 ENGLISH
Subject = ENGLISH and Subject = SCIENCEsays “Subject needs to be both ENGLISH and SCIENCE at the same time” which can never be true.Does this work for you?