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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| begin
FOR select t_stock.refarticle, t_stock.remlig, t_rupturestocks.nbsemaines_rupt_fini,
t_rupturestocks.nbsemaines_rupt_brut, sum(t_cumulca.cumulqte) as qte_vendu,
t_stock.stkminifini, t_stock.stkminibrut, t_stock.louchecde, t_stock.louchepla,
(t_stock.a + t_stock.t + t_stock.m + t_stock.r + t_stock.p + t_stock.s ) as qte_placage,
t_stock.f, (t_stock.b + t_stock.e) as qte_brut, sum(t_cumulcamoins.cumulqte) as qte_vendumoins,
t_cumulcastock.stkminifini, t_cumulcastock.stkminibrut
from t_stock
left outer join t_cumulca on (t_stock.refarticle = t_cumulca.refarticle)
left outer join t_rupturestocks on (t_stock.refarticle = t_rupturestocks.refarticle)
left outer join t_cumulca as t_cumulcamoins on (t_stock.refarticle = t_cumulcamoins.refarticle)
left outer join t_cumulca as t_cumulcastock on (t_stock.refarticle = t_cumulcastock.refarticle )
where
t_stock.remlig = :remlig and
t_cumulca.annee = extract(year from current_date)
and t_cumulcamoins.annee = (extract(year from current_date) -1)
and t_cumulcastock.annee = (extract(year from current_date) -1) and t_cumulcastock.mois = 12
group by t_stock.refarticle,t_stock.remlig, t_rupturestocks.nbsemaines_rupt_fini,
t_rupturestocks.nbsemaines_rupt_brut,t_stock.stkminifini, t_stock.stkminibrut, t_stock.louchecde,
t_stock.louchepla, qte_placage, t_stock.f, qte_brut, t_cumulcastock.stkminifini, t_cumulcastock.stkminibrut
union
select t_stock.refarticle, t_stock.remlig, t_rupturestocks.nbsemaines_rupt_fini,
t_rupturestocks.nbsemaines_rupt_brut, sum(t_cumulca.cumulqte) as qte_vendu,
t_stock.stkminifini, t_stock.stkminibrut, t_stock.louchecde, t_stock.louchepla,
(t_stock.a + t_stock.t + t_stock.m + t_stock.r + t_stock.p + t_stock.s ) as qte_placage,
t_stock.f, (t_stock.b + t_stock.e) as qte_brut, sum(t_cumulcamoins.cumulqte) as qte_vendumoins,
t_cumulcastock.stkminifini, t_cumulcastock.stkminibrut
from t_stock
left outer join t_cumulca on (t_stock.refarticle = t_cumulca.refarticle)
left outer join t_rupturestocks on (t_stock.refarticle = t_rupturestocks.refarticle)
left outer join t_cumulca as t_cumulcamoins on (t_stock.refarticle = t_cumulcamoins.refarticle)
left outer join t_cumulca as t_cumulcastock on (t_stock.refarticle = t_cumulcastock.refarticle )
where
t_stock.remlig = :remlig and t_stock.refarticle not in (select t_cumulca.refarticle from t_cumulca)
group by t_stock.refarticle,t_stock.remlig, t_rupturestocks.nbsemaines_rupt_fini,
t_rupturestocks.nbsemaines_rupt_brut,t_stock.stkminifini, t_stock.stkminibrut, t_stock.louchecde,
t_stock.louchepla, qte_placage, t_stock.f, qte_brut, t_cumulcastock.stkminifini, t_cumulcastock.stkminibrut
into
:refarticle,
:remligout,
:nbsemaines_rupt_fini,
:nbsemaines_rupt_brut,
:qte_vendu,
:stkminifini,
:stkminibrut,
:louchecde,
:louchepla,
:qte_placage,
:f,
:qte_brut,
:qte_vendumoins,
:stkminifinimoins,
:stkminibrutmoins
do
suspend;
end |
Partager