0

Hi
I have this query:

`SELECT SUM(`KN`) + SUM((COALESCE(`EUR`, 0)))*7.5 FROM log WHERE `KN` IS NOT NULL and `EUR` IS NOT NULL`

And it retunrs 0

SUM(EUR)* 7.5 should be zero but SUM(KN) is 60.

I am not shure what I am doing wrong here, I want to add numbers and avoid counting NULL so where is null to set 0 that I can add values

SELECT (SUM(EUR)* 7.5) FROM log WHERE EUR IS NOT NULL
returns 0
and
SELECT SUM(KN) FROM log WHERE KN IS NOT NULL
returns 60

Thanks

Edited by mehnihma

2
Contributors
1
Reply
10
Views
2 Years
Discussion Span
Last Post by lps
2

The query problem is because your 'And' statement. Means if EUR is null but KN IS NOT NULL, the query still will not get the data.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.