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
| cursor c_posit is
select
x.soci,
x.risk,
x.origin,
x.destin,
x.pack,
x.dev,
x.flg_p_s,
x.term,
x.annee_ref,
x.mois_ref,
sum(tot_qte_short) as tot_qte_short,
nvl(avg(avg_prix_flat),0) as avg_prix_flat
from
(
Select
s.soci,
s.risk,
s.origin,
s.destin,
s.pack,
s.dev,
s.flg_p_s,
s.term,
to_char(s.date_ship_deb, 'YYYY') "ANNEE_REF",
to_char(s.date_ship_deb, 'MM') "MOIS_REF",
s.qte_EXEC_solde as "TOT_QTE_SHORT",
(select e.MT_COST_RISK/e.qte_appliquee from estcost e where s.contrat = e.CONTRAT(+) and
s.sect = e.sect(+) and e.mt_cost <> 0 and E.COST in ('FRET', 'BFRET')) as "AVG_PRIX_FLAT"
From
Sect S,
Term T
where s.Term = T.term
and s.soci = '56'
and s.qte_exec_solde <> 0
and s.risk = 'T711'
and T.BASIS = 'C'
and S.flg_p_s = 'S'
) x
group by
x.soci,
x.risk,
x.origin,
x.destin,
x.pack,
x.dev,
x.flg_p_s,
x.term,
x.annee_ref,
x.mois_ref; |
Partager