1 2 3 4 5 6 7 8 9 10 11 12 13 14
| (select DO_Tiers,CT_Intitule,(SUM (DL_MontantTTC)-SUM (RC_Montant))SOLDE from
(SELECT DO_Tiers,CT_Intitule,T1.DO_Piece,DO_Date,DL_MontantTTC,coalesce(RC_Montant,0)RC_Montant FROM
(select E.DO_Tiers,T.CT_Intitule,E.DO_Piece,E.DO_Date,SUM(DL.DL_MontantTTC)DL_MontantTTC
from F_DOCLIGNE DL,F_DOCENTETE E ,F_COMPTET T
where (E.DO_Piece=DL.DO_Piece) and (E.DO_Tiers=T.CT_Num)
and DL.DO_Domaine=0 and CT_Type=0 and (DL.DO_Type=6 or DL.DO_Type=7 )
GROUP BY E.DO_Tiers,T.CT_Intitule,E.DO_Piece,E.DO_Date) T1
LEFT OUTER JOIN
(select DO_Piece,SUM(RC_Montant)RC_Montant from F_REGLECH RH
where RH.DO_Domaine=0 and (RH.DO_Type=6 or RH.DO_Type=7 )
group by DO_Piece) T2
ON T1.DO_Piece=T2.DO_Piece ) T002
GROUP BY DO_Tiers,CT_Intitule ) |
Partager