1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Select Entfctclient.Commercial,Entfctclient.Client,Produit.Grdfamille,Produit.Famille,max(Produit.Famille) as pdfam,max(Famarticle.Libelle) as libfab,
max(Commerciaux.Nom) as Nomco, sum(Ligfctclient.qtefac*Ligfctclient.cdtcarton) as qteli, sum(Ligfctclient.mtligne) as mtht,
max(Clients.Nom) as Nomcli,max(Clients.Txcom) as Txcoms,sum(Ligfctclient.Qtefac*Remisecarton.Recar_Prime) as Prime,MIN(Txcom_Commercial.Txcom) as Txco,
sum(Ligfctclient.Pxrevient) as mtrev, sum(Ligfctclient.mtligne-Ligfctclient.Pxrevient) as marge,
min(Famarticle.taux) as tx1 , min(Famarticle.Tauxmarge) as Txmar,
(IIF(Tx1 > Txcoms,Tx1=Txcoms,Tx1))as Tx,
(IIF(Txmar is NULL or Txmar = 0.00 ,marge,mtht-((mtht * txmar) / 100))) as pourct,
((pourct * tx)/ 100 ) as mtcom
FROM
((((((Ligfctclient INNER JOIN Entfctclient ON Ligfctclient.Nufct = Entfctclient.Nufct)
LEFT JOIN Produit ON Produit.Nuart = Ligfctclient.Reference)
INNER JOIN Commerciaux ON Commerciaux.Code = Entfctclient.Commercial)
LEFT JOIN Famarticle ON (Famarticle.Gfam = Produit.Grdfamille) AND (Famarticle.Code = Produit.Famille))
INNER JOIN Clients ON Clients.Code = Entfctclient.Client)
INNER JOIN Remisecarton ON Remisecarton.Nuart = Ligfctclient.Reference)
LEFT JOIN Txcom_Commercial ON (Txcom_Commercial.Commercial = Commerciaux.Code) AND (Txcom_Commercial.Gfam = Produit.Grdfamille) AND (Txcom_Commercial.Famille = Produit.Famille)
GROUP BY Entfctclient.Commercial,Entfctclient.Client,Produit.Grdfamille,Produit.Famille
ORDER by Entfctclient.Commercial,Entfctclient.Client,Produit.Grdfamille,Produit.Famille |
Partager