Subject Re: [IBO] SQL Problens
Author Daniel Rail
At 03/04/2002 11:36 AM, you wrote:
>I need create one calc of sum of sales. In my Application i have "Discount
>by Item" and "Discount General", i need calc the sum of total sales. I use
>the line:
>SELECT SUM(b.PrItSale*b.QtItSale-DiscountItSale)-SUM(a.DiscountSale) FROM
>Sale a, ItSale b
>WHERE b.CodSale = a.CodSale
>The problem: i give one discount general it repeat the discount for all
>items of sale.

Try this statement:

(SUM(b.PrItSale*b.QtItSale-DiscountItSale)-SUM(a.DiscountSale)) as
FROM Sale a
JOIN ItSale b
ON (b.CodSale = a.CodSale)
GROUP BY a.CodeSale

Daniel Rail
Senior System Engineer
ACCRA Group Inc. (
ACCRA Med Software Inc. (