Manque une jointure dans cette requête
Bonjour,
J'ai une requête qui renvoie plusieurs fois la même ligne. Il manque une jointure visiblement mais je n'arrive pas à trouver où. Pourriez-vous m'aider ? Je suis sous Oracle 12.1. Voici la requête :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| with
r as (
select trunc(t.date_travaux, 'yyyy') date_travaux, sum(t.montant_facture) montant_facture from mv_entretien t
GROUP by trunc(t.date_travaux, 'yyyy')),
y as (select date1,cout_carburant from mv_cout_carburant where vehicule = :P13_VEHICULE)
select trunc(a.date_kilometrage, 'yyyy') "Année", a.kilometrage "Kilométrage", (r.montant_facture+y.cout_carburant)/a.kilometrage "Prix de revient km"
from mv_kilometrage a, r, y, mv_entretien z
where trunc(r.date_travaux, 'yyyy') = trunc(a.date_kilometrage, 'yyyy')
and trunc(y.date1, 'yyyy') = trunc(a.date_kilometrage, 'yyyy')
and a.vehicule=:P13_VEHICULE
AND z.type_travaux <> 4
order by a.date_kilometrage; |
Le résultat est :
01/01/2014 00:00:00 |
14806 |
0,0728751857355126300148588410104011887073 |
01/01/2014 00:00:00 |
14806 |
0,0728751857355126300148588410104011887073 |
01/01/2014 00:00:00 |
14806 |
0,0728751857355126300148588410104011887073 |
01/01/2015 00:00:00 |
26222 |
0,0412783159179315078941346960567462436122 |
01/01/2015 00:00:00 |
26222 |
0,0412783159179315078941346960567462436122 |
01/01/2015 00:00:00 |
26222 |
0,0412783159179315078941346960567462436122 |
01/01/2016 00:00:00 |
38950 |
0,0223211810012836970474967907573812580231 |
01/01/2016 00:00:00 |
38950 |
0,0223211810012836970474967907573812580231 |
01/01/2016 00:00:00 |
38950 |
0,0223211810012836970474967907573812580231 |
01/01/2017 00:00:00 |
48827 |
0,1086548426075736784975525836115264095685 |
01/01/2017 00:00:00 |
48827 |
0,1086548426075736784975525836115264095685 |
01/01/2017 00:00:00 |
48827 |
0,1086548426075736784975525836115264095685 |
Merci pour votre aide.