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: calculated fields and divide by zero

Re: calculated fields and divide by zero

From: Alton Ayers <altona_at_ditw.com>
Date: Tue, 21 Jul 1998 16:40:09 -0400
Message-ID: <35B4FCA8.17DF82D@ditw.com>


Try this:

SELECT DECODE(sales,0,0,(sales-margin)/sales) FROM ...

Alton

Kevin Skaalrud wrote:

> Thanks to Thomas Kyte for sovling my this year vs
> last year query.
>
> My next problem is this: when I try to calculate
> GP%, say, (sales-margin)/sales, if sales is zero
> oracle aborts the query with a divide by zero error.
>
> Any thoughts on how to avoid this behaviour. I would
> prefer to see INF or 0 returned instead of abend on
> the query.
>
> Kevin Skaalrud
Received on Tue Jul 21 1998 - 15:40:09 CDT

Original text of this message

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