1 2 3 4 5
| with s as (select trunc(date1, 'YYYY') as year1, sum(cout_carburant) as cout_carburant1, sum(kilometrage) as km from mv_cout_carburant where vehicule = :P13_VEHICULE group by trunc(date1, 'YYYY') order by 1),
y as (select trunc(t.date_travaux, 'yyyy') as date_travaux, sum(nvl(t.montant_facture,0)) as montant_facture1 from mv_entretien t where vehicule=:P13_VEHICULE GROUP by trunc(t.date_travaux, 'yyyy'))
select year1, cout_carburant1, km, cout_carburant1+nvl(montant_facture1,0) "carburant+factures", nvl(montant_facture1,0) "Factures", round ( (cout_carburant1+nvl(montant_facture1,0))/KM, 3) "PRK" from s, y
where s.year1 = y.date_travaux (+)
order by year1; |
Partager