1 2 3 4 5 6 7 8 9 10 11 12 13
| with
r as (
select trunc(t.date_travaux, 'yyyy') date_travaux, sum(t.montant_facture) montant_facture from mv_entretien t where vehicule=:P13_VEHICULE
GROUP by trunc(t.date_travaux, 'yyyy'), t.vehicule),
y as (select trunc(date1, 'YYYY'), sum(cout_carburant) from mv_cout_carburant where vehicule = :P13_VEHICULE group by trunc(mv_cout_carburant.date1, 'YYYY'))
select trunc(a.date1, 'YYYY') "Année", sum (a.kilometrage) "Kilométrage", sum ((r.montant_facture+y.cout_carburant)/a.kilometrage) "Prix de revient km"
from mv_cout_carburant a, r, y
where
trunc(y.date1, 'yyyy') = trunc(a.date1, 'yyyy')
and
a.vehicule=:P13_VEHICULE
group BY trunc (a.date1, 'YYYY')
order by trunc(a.date1, 'yyyy'); |
Partager