Re: How do I make 2 + Null = 2 ?
From: Richard Bennett <richhb_at_sequent.com>
Date: 1996/02/19
Message-ID: <4gaf9e$gva_at_scel.sequent.com>#1/1
Date: 1996/02/19
Message-ID: <4gaf9e$gva_at_scel.sequent.com>#1/1
Russell Foster <Russell_Foster_at_mmacmail.jccbi.gov> wrote:
>I am writing a select statement for Oracle7-NT that needs to return a
>derived column that is the result of an arithmetic operation between two
>other columns. Ex: select col1, col2+(.5*(col3)) as derivedcol from
>table1;
>
>I would like to know a way to write this in a way that treats a null col3
>as zero for the math, returning the value of col2 as derivedcol if col3
>is null. The statement must be dynamic SQL.
Use the nvl function to return zero when the column value is null. Ex: select col1, col2+(.5*(nvl(col3,0)))
-- =============================================================== Richard Bennett E-Mail: richhb_at_sequent.com 73501.1703_at_compuserve.com Computer People Inc. On contract to Sequent Computer SystemsReceived on Mon Feb 19 1996 - 00:00:00 CET