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
| /* Utilisation d'une CTE (expression de table commune) */
with
/* calcul de la moyenne de l'indice de boue dans le bassin d'aération */
Compte_Moyenne_IB_BA (step, ouvrage, moy_ib)
as
(select b.nom_step, c.designation_ouvrage, avg(a.indice_boue)
from tb_indice_boue a
inner join tb_step b on (b.code_step = a.code_step)
inner join tb_point_prlv c on (c.code_point_prlv = a.code_point_prlv)
where ( (a.date_bilan between :d_debut and :d_fin) and
c.code_point_prlv = 3 /* code bassin d'aération */)
group by b.nom_step, c.designation_ouvrage
),
/* calcul de la moyenne de l'indice de boue dans le clarificateur */
Compte_Moyenne_IB_CL (step, ouvrage, moy_cl)
as
(select b.nom_step, c.designation_ouvrage, avg(a.indice_boue)
from tb_indice_boue a
inner join tb_step b on (b.code_step = a.code_step)
inner join tb_point_prlv c on (c.code_point_prlv = a.code_point_prlv)
where ( (a.date_bilan between :d_debut and :d_fin) and
c.code_point_prlv = 8 /* code clarificateur */)
group by b.nom_step, c.designation_ouvrage
)
select /* affichage du nom de la STEP */
Compte_Moyenne_IB_BA.step,
/* affichage du Ratio */
(cast(Compte_Moyenne_IB_BA.moy_ib as float)/Compte_Moyenne_IB_CL.moy_cl) Ratio_IB
from Compte_Moyenne_IB_CL, Compte_Moyenne_IB_BA
where ( Compte_Moyenne_IB_BA.STEP = Compte_Moyenne_IB_CL.STEP ) |
Partager