Bonjour,

dans une requête sql qui se décompose en plusieurs requêtes, dans la requête finale qui affiche les résultats, j'ai une colonne total qui est une somme de 3 colonnes (où les informations sont mises dans 3 tables temporaires différentes) or si je n'ai pas de résultat dans la 3ème colonne , il ne fait pas le total

La 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
32
33
34
35
36
37
38
39
40
41
42
43
select num numtab1, gam, nom, pre, dan, 
'['||ser||'] '||slib service, 
'['||ufo||'] '||ulib ufresult,dat, das, rss, grp 
from tabh, tabp, tabser,tabu
where and tabser.sermsi = 1  
and ser in (PARAM3) 
and tabp.pndo = tabh.hndo 
and tabh.ser = tabser.cod 
and tabh.ufo = tabu.ucod
order by gam,das 
into temp taberesult1
 
select service,ufresult,count(*)nbsansdp from taberesult1
group by 1,2
into temp tab1;
 
select nom,pre,dan,num,gam,rss,'['||ufo||'] '||ulib ufresult,'['||ser||'] '||slib service,dat,das 
from tabh,tabp,tabser,tabu
where and tabp.pndo = tabh.hndo 
and tabh.num not in (select nsj from tabrum)
and tabh.num not in (select numtab1 from taberesult1)
and das between PARAM1 and PARAM2 
and ser in (PARAM3) 
and tabh.ser = tabser.cod
and tabh.ufo = tabu.ucod
into temp taberesult2;
 
select service,ufresult,count(*) nbsansnumrss from taberesult2
group by 1,2
into temp tab2;
 
 
select nosej,numrss,'['||unite||'] '||ulib ufresult,'['||rser||'] '||slib service,entdat,sordat 
from tabrum,tabser,tabu
where sordat between PARAM1 and PARAM2 
and tabrum.rser in (PARAM3) 
and tabrum.rser = tabser.cod
and tabrum.unite = tabu.ucod
into temp taberesult3;
 
select service,ufresult,count(*) nbavecnumrss from taberesult3
group by 1,2
into temp tab3;
requete affichant le résultat final :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
select tab3.service,tab3.ufresult,tab1.nbsansdp,tab2.nbsansnumrss,tab3.nbavecnumrss,(tab1.nbsansdp+tab2.nbsansnumrss+tab3.nbavecnumrss) restotal, round((((tab1.nbsansdp+tab2.nbsansnumrss)/(tab1.nbsansdp+tab2.nbsansnumrss+tab3.nbavecnumrss))*100),2) pourcentage
from outer(tab1),outer(tab2),tab3
where tab1.ufresult=tab3.ufresult
and tab2.ufresult=tab3.ufresult
order by tab3.service;
Voici le resultat que j'obtiens :

[11] U [8227] DU 3 155
[17] P [0425] HNLA 31
[23] CG [4010] CGV 2 3 117 122 4,1
[97] HSPC[4900] HSPC 4 130
Comment je peux faire pour que dans RESTOTAL j'aie bien le total même si je n'ai pas d'informations dans la colonne tab1.nbsansdp ou dans la colonne tab2.nbsansnumrss ?
merci