Skip to content
Advertisement

Why does my SQL Statement not SUM() up correctly?

I have the following statement:

note that = (1 or 4) refers to two statements in the database where 1 is sold and 4 is a refund.

With = (1)) I get the following results:

Costs – Unitamounts 3.281,10 – 582

With = (4)) I get the following results:

Costs – Unitamounts -115,2 – -32

With = (1 or 4)) I get the following results:

Costs – Unitamounts 3.281,10 – 582

But I expect as a correct SUM() of it:

Costs – Unitamounts 3.165,9 – 550

What am I doing wrong that the results are not subtracted correctly?

Advertisement

Answer

You probably meant to do:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement