Subject | Re[2]: [firebird-support] NULLS in VIEW when adding values |
---|---|
Author | Helen Borrie |
Post date | 2006-03-11T13:54:37Z |
At 11:38 PM 11/03/2006, you wrote:
Sorry.
Helen
>Hello Helen,Quite so, I missed the main point, that he wanted to count negatives as zero.
>
>HB> If I understand the question, this will do the job just fine:
>HB> select Nr1, Nr2, coalesce(Nr1, 0) + coalesce(Nr2, 0) as NrTotal
>from ATable
>
>The author of the question wants to get a sum of non-negative and values
>only. So, I suppose he may use CASE statement here (almost as he
>suggested in his post):
>-----
>select Nr1, Nr2,
> case when (Nr1 is not null) and (Nr1 >= 0) then Nr1 else 0 end +
> case when (Nr2 is not null) and (Nr2 >= 0) then Nr2 else 0 end
> as NrTotal from ATable
>-----
Sorry.
Helen