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

Home -> Community -> Usenet -> c.d.o.misc -> Re: sql

Re: sql

From: Michael Ringbo <mhr_at_NOSPAMramboll.dk>
Date: Mon, 04 Oct 1999 13:43:54 +0200
Message-ID: <37F892FA.215BED8D@NOSPAMramboll.dk>


Hi,

You gotta use decode:

create or replace view myview as
select col1, col2, decode(col2,0,0,(col1/col2)*1000000) col3 from mytable

Hope this helps

regards, Michael Ringbo

daud11_at_hotmail.com wrote:

> Hi
>
> I need to create a view where the code looks something like below.
>
> create or replace view myview as
> select col1, col2, (col1/col2)*1000000 col3
> from mytable
>
> However, it is possible that col2 contains some zero values and when
> there zeroes the view will break. I want col3 (calculated) to be 0 when
> col2 is 0. How do I change the sql to do just that with using UNION?
>
> Thanks
> Daud
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Mon Oct 04 1999 - 06:43:54 CDT

Original text of this message

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