1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| select s.nom_step, f.date_bilan,
sum(f.montant) charge,
max(e.montant_facture_ht) energie,
max(p.volume_mj_sortie * p.nombre_jour_reel) volume,
((max(e.montant_facture_ht) + max(p.volume_mj_sortie * p.nombre_jour_reel))
/ (max(p.volume_mj_sortie * p.nombre_jour_reel))) prix_revient,
-- comment faire pour calculer le prix de revient moyen par STEP ?
from tb_step s
inner join tb_frais_bilan_2014 f on (s.code_step = f.code_step)
inner join tb_energie e on (s.code_step = e.code_step)
and e.date_mois = f.date_bilan
inner join tb_process p on (s.code_step = p.code_step)
and p.date_bilan = f.date_bilan
group by s.nom_step, f.date_bilan
order by s.nom_step, f.date_bilan |