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 -> Complicated SQL Query... help?

Complicated SQL Query... help?

From: <dolans_at_my-deja.com>
Date: Thu, 21 Oct 1999 18:02:27 GMT
Message-ID: <7unkfg$d1g$1@nnrp1.deja.com>


I have 2 queries where I get the Subjects that someone is currently enrolled in and another where the query retrieves ALL the subjects. I am trying to present a list to the user of those classes they haven't signed up for yet:

I could do a MINUS operation to remove those classes they are already in, but I need to do a group by as well. Here is the query, maybe you can help. Thanks, Sean

Query :
SELECT ALL s.PERIOD, s.SUBJECT_DESCR,
po.ORDINALITY, s.SUBJECT_ID
FROM CTB.SUBJECT s, CTB.PERIODS_OFFERED po WHERE s.CONTRACT_ID=1
 AND (s.PERIOD=po.PERIOD
 AND s.CONTRACT_ID=po.CONTRACT_ID)
MINUS
(SELECT ALL s.PERIOD, s.SUBJECT_DESCR, po.Ordinality, s.SUBJECT_ID FROM CTB.SUBJECT s, CTB.USER_SUBJECT_ACCESS usa, CTB.PERIODS_OFFERED po WHERE usa.USERNAME='foo'
AND (usa.SUBJECT_ID=s.SUBJECT_ID)
AND (po.period = s.period)
)
GROUP BY s.PERIOD, s.SUBJECT_DESCR,
po.ORDINALITY, s.SUBJECT_ID
ORDER BY po.ORDINALITY ASC

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Thu Oct 21 1999 - 13:02:27 CDT

Original text of this message

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