Gossamer Forum
Home : Products : Gossamer Links : Discussions :

select sum problem

Quote Reply
select sum problem
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!!!
Subject Author Views Date
Thread select sum problem bobthesnake 1931 May 28, 2003, 7:11 AM
Post Re: [bobthesnake] select sum problem
Andy 1892 May 28, 2003, 7:22 AM
Thread Re: [bobthesnake] select sum problem
Paul 1874 May 28, 2003, 9:35 AM
Post Re: [Paul] select sum problem
bobthesnake 1838 May 30, 2003, 4:55 AM