Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Select
Mark McCubbin wrote:
> I need help with an SQL query to determine which students have taken two
> or more courses. For example, what is the most efficient way to answer
> the question: who has taken all three classes CS101, CS200, and CS300?
> The tables are as follows (the relationship is one to many):
>
> STUDENT
> StudentID
> FirstName
> LastName
> TAKEN
> ClassTitle
> StudentID
It was a short night (just a meeting yesterday evening if you're interested), so I may be wrong, but this might be a possibility (the intersect-solution in the other post may be better):
select s.FirstName, s.LastName, s.StudentId
from Student s, Taken t
where s.StudentId = t.StudentId
and t.ClassTitle in ('CS101','CS200','CS300')
group by s.FirstName, s.LastName, s.StudentId
having count(*) = 3;
Marc Received on Wed Oct 01 1997 - 00:00:00 CDT
![]() |
![]() |