Bonjour,
voici les tables et les champs dont j'ai besoin pour ma requête:
C_QUESTION (NIQ,LIBABR) (table de questions)
BM_REP_S (NIR,REPONSE,NILIB) (table de reponses)
BM_LIB_S (NILIB,NIQ,NIQSUP,NILIBSUP,PARENTE) (table de correspondance entre les question-reponse et leur questions mère)
le lien entre la question et sa question mère se fait grace au champ NIQSUP
exemple:
C_QUESTION.NIQ = 1, C_QUESTION.LIBABR = 'sous question'
BM_REP_S.NILIB = 1, BM_REP_S.REPONSE = 'reponse de la sous question'
BM_LIB_S.NILIB = 1, BM_LIB_S.NILIB =1, BM_LIB_S.NIQSUP = 2, BM_LIB_S.NILIBSUP = 2
on peut trouver les question mère et la réponse mère
C_QUESTION.NIQ = 2 => C_QUESTION.LIBABR = 'question mère'
et BM_REP_S.NILIB = 2 => BM_REP_S.REPONSE = 'reponse de la question mère'
voici ma requête principale!je souhaite intégrer dans mes champs de selection :la date d'examen, qui est une réponse de la question "Date de l'examen"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 select q3.LIBABR,r3.REPONSE 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 and lib2.NIQSUP is NULL and lib2.NILIBSUP is NULL and not exists (select lib1.NIQSUP from PENSOINS.BM_LIB_S lib1 where lib1.PARENTE like '674,%' and lib2.NIQ = Lib1.NIQSUP) ORDER BY 2,5
voici la sous requête:j'ai essayé ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 select r4.REPONSE from PENSOINS.BM_LIB_S lib4, PENSOINS.C_QUESTION q4,PENSOINS.BM_REP_S r4 where lib4.PARENTE like '674,%' and lib4.NIQ = q4.NIQ and lib4.NILIB = r4.NILIB and q4.LIBABR like 'Date de l%'même après 10 mn la requête n'est pas encore executée !!
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 select r4.REPONSE as "date examen",q3.LIBABR,r3.REPONSE from PENSOINS.BM_LIB_S lib2,PENSOINS.BM_REP_S r4, PENSOINS.C_QUESTION q3,PENSOINS.BM_REP_S r3, PENSOINS.BM_TH_S th,PENSOINS.SEJOUR sj, PENSOINS.PATIENT p where lib2.PARENTE like '674,%' and lib2.NIQ = q3.NIQ and lib2.NILIB = r3.NILIB and lib2.NIQSUP is NULL and lib2.NILIBSUP is NULL and not exists (select lib1.NIQSUP from PENSOINS.BM_LIB_S lib1 where lib1.PARENTE like '674,%' and lib2.NIQ = Lib1.NIQSUP) and exists (select r4.REPONSE from PENSOINS.BM_LIB_S lib4,PENSOINS.BM_REP_S r4 where lib4.PARENTE like '674,%' and lib4.NIQ = q3.NIQ and lib4.NILIB = r4.NILIB and q3.LIBABR like 'Date de l%')
je vous remercie d'avance
Partager