Bonjour,

Je travaille sous Orcale 9i, voici les 3 tables concerné et les champs concernés par ma requête:
C_QQUESTION (NIQ,LIBABR)
BM_REP_S (NIR,REPONSE,NILIB)
BM_LIB_S (NILIB,NIQ,NIQSUP,NIRSUP,PARENTE)

Cette structure me permet de trouver les question reponses, les sous questions reponses (s'ils existent) et les sous sous questions reponses (s'ils existent). le NIQSUP fait reference au NIQ de la question mère, et le NILIBSUP fait reference à la reponse mère, quand ils sont à NULL, c'est que cette question n'a pas de question mère.

voici ma requête:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
select distinct q3.LIBABR,r3.REPONSE,NULL,NULL,NULL,NULL
from PENSOINS.BM_LIB_S lib2,
PENSOINS.C_QUESTION q3,PENSOINS.BM_REP_S r3
where lib2.PARENTE like '674,%'
and lib2.NIQ = q3.NIQ
and lib2.NILIB = r3.NILIB
UNION
select distinct q3.LIBABR,r3.REPONSE,q2.LIBABR,r2.REPONSE,NULL,NULL
from PENSOINS.BM_LIB_S lib2,
PENSOINS.C_QUESTION q2,PENSOINS.BM_REP_S r2, 
PENSOINS.C_QUESTION q3,PENSOINS.BM_REP_S r3
where lib2.PARENTE like '674,%'
and q2.NIQ = lib2.NIQ
and r2.NILIB = lib2.NILIB
and lib2.NIQSUP = q3.NIQ
and lib2.NILIBSUP = r3.NILIB
UNION
select distinct q3.LIBABR,r3.REPONSE,q2.LIBABR,r2.REPONSE, q1.LIBABR,r1.REPONSE
from PENSOINS.BM_LIB_S lib1,PENSOINS.BM_LIB_S lib2, 
PENSOINS.C_QUESTION q1, PENSOINS.BM_REP_S r1, 
PENSOINS.C_QUESTION q2,PENSOINS.BM_REP_S r2, 
PENSOINS.C_QUESTION q3,PENSOINS.BM_REP_S r3
where lib1.NIQ = q1.NIQ
and  lib1.NILIB = r1.NILIB
and lib1.PARENTE like '674,%'
and lib1.NIQSUP = q2.NIQ
and lib1.NILIBSUP = r2.NILIB
and q2.NIQ = lib2.NIQ
and r2.NILIB = lib2.NILIB
and lib2.NIQSUP = q3.NIQ
and lib2.NILIBSUP = r3.NILIB
mon problème est que pour une question de type "ATCD respiratoires" le médecin à plusieurs choix soit il peut cocher "Asthme" ou "Sarcoïdose" ou "Embolie pulmonaire"...etc, mais seulement quand on coche "Asthme" il y'a une sous question qui apparait "Age lors découverte de l'asthme".
Dans le resultat de ma requête ci-dessous, j'obtiens parmis les questions, la question "ATCD respiratoires", et comme reponse "NULL" (pour les patients qui n'ont pas d'ATCD respiratoires), mais j'obtiens quand même une sous question "Age lors découverte de l'asthme" avec une reponse.
ce problème est du au fait que lorsqu'il n'y a pas de réponse le BM_REP_S .NILIB est "NULL"

j'ajoute que je n'ai pas les droit pour changer la structure de la base!!

je vous remercie d'avance.