Subject | Re: [firebird-support] Force NULL to zero in calculation? |
---|---|
Author | Martijn Tonies |
Post date | 2004-08-17T17:06:55Z |
Hi,
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com
> Take the following query:With Firebird 1.5, you can use COALESCE.
>
> select (saleprice-salecost-saletradein) as Profit
> from sales where saledate = '08/08/04'
>
> The problem is that if saletradein is NULL, then the resulting Profit is
> also null. That's not what I want. If saletradein is null, I want it to
> assume zero for that field. For instance 100 - 25 - NULL = 75. I know
> that logically, that's not technically correct, but that's the effect that
> I want.
>
> Is there any way to write the query so that it works that way?
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com