Hello,
Can someone help me out with this: I'm trying to get the sum of values of different records.
Here's what I tried: SELECT SUM (fiche.CA) as number FROM fiche, lignefiche, produit WHERE fiche.Date ='$date' and produit.Type = 'type1' and fiche.Num = lignefiche.Numfic and lignfiche.Numpro = produit.Numpro
fiche, lignefiche and produit are the three tables. If fiche refers to more than one lignefiche, the result of the query is wrong.
example: fiche1.CA = 200 and fiche2.CA = 100, lignefiche1 and lignefiche2 refers to fiche1, lignefiche3 refers to fiche2, the sum will be 500, but it should be 300...
I hope you can understand my problem... thanks!!!
Can someone help me out with this: I'm trying to get the sum of values of different records.
Here's what I tried: SELECT SUM (fiche.CA) as number FROM fiche, lignefiche, produit WHERE fiche.Date ='$date' and produit.Type = 'type1' and fiche.Num = lignefiche.Numfic and lignfiche.Numpro = produit.Numpro
fiche, lignefiche and produit are the three tables. If fiche refers to more than one lignefiche, the result of the query is wrong.
example: fiche1.CA = 200 and fiche2.CA = 100, lignefiche1 and lignefiche2 refers to fiche1, lignefiche3 refers to fiche2, the sum will be 500, but it should be 300...
I hope you can understand my problem... thanks!!!