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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| select do_piece, do_date, ct_num, dl_ligne, ar_ref, ar_refcompose, dl_design, dl_qte, dl_montantht/dl_qte as pu,
co_nom, dl_montantht, dl_montantht, 0, pa,cr, comintermediaire, margepcent, marge, ajustpa, pa_rectifie
from
f_docligne
left join f_collaborateur RepDoc on f_docligne.CO_No = Repdoc.co_no
where
ar_ref = ar_refcompose
and ar_refcompose is not null
and ar_refcompose <>''
and dl_qte<>0
and do_piece in
(
select
f_docentete.do_piece
from bor_view_docligne_ctrl,
f_docentete
left join f_collaborateur RepDoc on f_docligne.CO_No = Repdoc.co_no
where
bor_view_docligne_ctrl."do_piece" = f_docentete.do_piece
and bor_view_docligne_ctrl."do_type" = f_docentete.do_type
and bor_view_docligne_ctrl."do_domaine" = f_docentete.do_domaine
and (
(bor_view_docligne_ctrl."total_ht_from_composant" - bor_view_docligne_ctrl."total_ht")>0.5
or (bor_view_docligne_ctrl."total_ht_from_composant" - bor_view_docligne_ctrl."total_ht")<-0.5
)
and year(f_docentete.do_date)>2008
and f_docentete.do_type<7
)
union all
select do_piece, do_date, ct_num, dl_ligne, ar_ref, ar_refcompose, dl_design, dl_qte, dl_montantht/dl_qte as pu,
co_nom, 0, 0, dl_montantht, pa,cr, comintermediaire, margepcent, marge, ajustpa, pa_rectifie
from
f_docligne
left join f_collaborateur RepDoc on f_docligne.CO_No = Repdoc.co_no
where
ar_ref <> ar_refcompose
and ar_refcompose is not null
and ar_refcompose <>''
and dl_qte<>0
and do_piece in
(
select
f_docentete.do_piece
from bor_view_docligne_ctrl,
f_docentete
left join f_collaborateur RepDoc on f_docentete.CO_No = Repdoc.co_no
where
bor_view_docligne_ctrl."do_piece" = f_docentete.do_piece
and bor_view_docligne_ctrl."do_type" = f_docentete.do_type
and bor_view_docligne_ctrl."do_domaine" = f_docentete.do_domaine
and (
(bor_view_docligne_ctrl."total_ht_from_composant" - bor_view_docligne_ctrl."total_ht")>0.5
or (bor_view_docligne_ctrl."total_ht_from_composant" - bor_view_docligne_ctrl."total_ht")<-0.5
)
and year(f_docentete.do_date)>2008
and f_docentete.do_type<7
)
union all
select do_piece, do_date, ct_num, dl_ligne, ar_ref, ar_refcompose, dl_design, dl_qte, dl_montantht/dl_qte as pu,
co_nom, dl_montantht, 0, 0, pa,cr, comintermediaire, margepcent, marge, ajustpa, pa_rectifie
from
f_docligne
left join f_collaborateur RepDoc on f_docligne.CO_No = Repdoc.co_no
where
(ar_refcompose is null
or ar_refcompose ='')
and dl_qte<>0
and do_piece in
(
select
f_docentete.do_piece
from bor_view_docligne_ctrl,
f_docentete
left join f_collaborateur RepDoc on f_docentete.CO_No = Repdoc.co_no
where
bor_view_docligne_ctrl."do_piece" = f_docentete.do_piece
and bor_view_docligne_ctrl."do_type" = f_docentete.do_type
and bor_view_docligne_ctrl."do_domaine" = f_docentete.do_domaine
and (
(bor_view_docligne_ctrl."total_ht_from_composant" - bor_view_docligne_ctrl."total_ht")>0.5
or (bor_view_docligne_ctrl."total_ht_from_composant" - bor_view_docligne_ctrl."total_ht")<-0.5
)
and year(f_docentete.do_date)>2008
and f_docentete.do_type<7
)
;; |
Partager