Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: calc field

Re: calc field

From: Brian Peasland <dba_at_remove_spam.peasland.com>
Date: Tue, 30 Sep 2003 20:07:56 GMT
Message-ID: <3F79E29C.D83C207D@remove_spam.peasland.com>


You can't multiply NULL times a value. That just doesn't make sense. However, you can test for NULL with the DECODE function and have it display one value if NULL and another if not NULL. For instance:

SELECT DECODE(productPrice,NULL,WarehousePrice*1.5,productPrice*1.5) as "NewPrice" FROM......

HTH,
Brian

Roger Smith wrote:
>
> Need suggestions on how to accomplish this, I know you can create a
> calculated field in sql:
>
> select (productPrice * 1.5) as "NewPrice"
>
> but my calc field is complicated by if then, if productPrice not null then
>
> select (productPrice * 1.5) as "NewPrice" else
>
> select (WarehousePrice * 1.5) as "NewPrice"
>
> and so on... can this be done in sql?
>
> Roger

-- 
===================================================================

Brian Peasland
dba_at_remove_spam.peasland.com

Remove the "remove_spam." from the email address to email me.


"I can give it to you cheap, quick, and good. Now pick two out of
 the three"
Received on Tue Sep 30 2003 - 15:07:56 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US