Home » SQL & PL/SQL » SQL & PL/SQL » Devided by zero in query (10g)
Devided by zero in query [message #413761] Fri, 17 July 2009 10:18 Go to next message
mamalik
Messages: 266
Registered: November 2008
Location: Pakistan
Senior Member

Dear All,

I have a query which divides column "A" by "B", but "B" column can contain zero. Query messages "Divisor is equal to zeor".

What may be solution?

select 1/0 from dual


thanks in advance.

Regards.
Asif.
Re: Devided by zero in query [message #413762 is a reply to message #413761] Fri, 17 July 2009 10:19 Go to previous messageGo to next message
BlackSwan
Messages: 25040
Registered: January 2009
Location: SoCal
Senior Member
WHERE B <> 0
Re: Devided by zero in query [message #413764 is a reply to message #413761] Fri, 17 July 2009 10:22 Go to previous messageGo to next message
Michel Cadot
Messages: 64119
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
case b when 0 then 1 else b

Regards
Michel

[Updated on: Fri, 17 July 2009 10:23]

Report message to a moderator

Re: Devided by zero in query [message #413766 is a reply to message #413761] Fri, 17 July 2009 10:26 Go to previous messageGo to next message
mamalik
Messages: 266
Registered: November 2008
Location: Pakistan
Senior Member

Dear Michle Uncle.

We have to include that row where column "B" Is Zero therefore
Quote:
WHERE B <> 0

is not valid,

is there any other solution with out "Case Statment".

I have no problem in "Case Statement" But i want to solve it without "Case Statement"

Regards.
Asif.
Re: Devided by zero in query [message #413768 is a reply to message #413761] Fri, 17 July 2009 10:34 Go to previous messageGo to next message
BlackSwan
Messages: 25040
Registered: January 2009
Location: SoCal
Senior Member
>We have to include that row where column "B" Is Zero therefore
What is desired/expected results from A/0?

Re: Devided by zero in query [message #413771 is a reply to message #413766] Fri, 17 July 2009 10:38 Go to previous messageGo to next message
Michel Cadot
Messages: 64119
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
mamalik wrote on Fri, 17 July 2009 17:26
Dear Michle Uncle.

We have to include that row where column "B" Is Zero therefore
Quote:
WHERE B <> 0

is not valid,

is there any other solution with out "Case Statment".

I have no problem in "Case Statement" But i want to solve it without "Case Statement"

Regards.
Asif.

Use DECODE

Regards
Michel

Re: Devided by zero in query [message #413842 is a reply to message #413761] Fri, 17 July 2009 15:41 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
select decode(my_col,0,0,(other_col/my_col)) result
from my_table;
Previous Topic: Database Trigger Error
Next Topic: ORA-20000: ORU-10027: buffer overflow, limit of 1000000 bytes
Goto Forum:
  


Current Time: Tue Dec 06 08:46:56 CST 2016

Total time taken to generate the page: 0.10788 seconds