Subject | Re[2]: [firebird-support] NULLS in VIEW when adding values |
---|---|
Author | Pavel Menshchikov |
Post date | 2006-03-11T12:38:56Z |
Hello Helen,
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
-----
(Erik, please refer to release notes for the CASE syntax).
--
Best regards,
Pavel Menshchikov
http://www.ls-software.com
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
-----
(Erik, please refer to release notes for the CASE syntax).
--
Best regards,
Pavel Menshchikov
http://www.ls-software.com