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: Help!!! on SqlPlus query

Re: Help!!! on SqlPlus query

From: Pierre Q.T. Nguyen <pqtn_at_videotron.ca>
Date: Fri, 9 Apr 1999 23:40:18 -0400
Message-ID: <5LzP2.725$Cb3.15805@weber.videotron.net>


SELECT T1.name_h ,

                    T2.name_m ,
                    count(T4.code_patient)
FROM        Hospital  T1 ,
                    Medecin  T2 ,
                    Hos_med  T3 ,
                    Med_pat_hos  T4
WHERE    T4.code_h (+) = T3.code_h
     and        T4.code_m (+) = T3.code_m
     and        T1.code_h = T3.code_h
     and        T2.code_m = T3.code_m

GROUP BY T1.name_h , T2.name_m

At first, I didn't know why you had the Hos_med table.... but it makes sense that a doctor works in an hospital with no patient in this hospital...

With that query, you'll have these relations (hospital,medecin) with no patient...

PQTN. Hongbo Zhang wrote in message <2DmP2.899$0C1.109214_at_carnaval.risq.qc.ca>...
>Hi,
>
>I am new on Oracle. I have 4 following tables:
>
>HOSPITAL:
>-------------------------
>CODE_H | NAME_H |
>--------------------------
>
>MEDECIN:
>--------------------------
>CODE_M | NAME_M |
>--------------------------
>
>HOS_MED:
>---------------------------
>CODE_H | CODE_M |
>--------------------------
>
>MED_PAT_HOS:
>-----------------------------------------------
>CODE_M | CODE_H | CODE_PATENT |
>----------------------------------------------
>
>Would you please help me to realize this query with Oracle Sqlplus: for
>every MEDECIN,
>find the name of hospital he works and count the nomber of patients he
>treats.
>
>Thanks
>
>Hongbo
>
>
Received on Fri Apr 09 1999 - 22:40:18 CDT

Original text of this message

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