Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Select

Re: SQL Select

From: Marc Billiet <Marc.Billiet_at_alcatel.be>
Date: 1997/10/01
Message-ID: <3431E967.1F7F@alcatel.be>#1/1

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US