Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: calculated fields and divide by zero
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
![]() |
![]() |