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: SQLPLUS divide by zero question

Re: SQLPLUS divide by zero question

From: Mungo Henning <mungoh_at_itacs.strath.ac.uk>
Date: Tue, 25 Aug 1998 10:45:37 +0100
Message-ID: <35E287C1.1A950405@itacs.strath.ac.uk>


Shouldn't that be:

        select decode(sum(B),0,0,sum(A)/sum(B)) from table T; because if "sum(B)" matches "0" then you want to return something (I picked zero), otherwise you want to do the divide?

Happy to be corrected...
Mungo Henning :-)

John P. Higgins wrote:
>
> select decode(sum(B),0,sum(A)/sum(B)) from table T;
>
> Iancrozier wrote:
>
> > I am trying to run a sql statement, something like this:
> >
> > select sum(A)/sum(B) from table T;
> >
> > Sometimes sum(B) is equal to zero. Is there any way in sqlplus I can run this
> > or
> > do I have to go to PL/SQL?
> >
> > Thanks in advance.
Received on Tue Aug 25 1998 - 04:45:37 CDT

Original text of this message

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