SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Divide by Zero Error Counter
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

indr4w
Starting Member

Indonesia
27 Posts

Posted - 07/14/2013 :  22:33:07  Show Profile  Reply with Quote
Hi..all,
How to solve divide by zero error when I need to display
all records in query?
Example:
CodeItem QtyOK Target
A 50 0
B 100 50
C 0 50

The query should resulting records like this :
CodeItem QtyOk Target Percent(QtyOk/Target)
A 50 0 0
B 100 50 200
C 0 50 0

Thank you.

MuMu88
Aged Yak Warrior

547 Posts

Posted - 07/14/2013 :  22:56:55  Show Profile  Reply with Quote
Try:

QtyOk / NULLIF(Target,0)
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22754 Posts

Posted - 07/23/2013 :  05:08:00  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
or in General

QtyOk / case when Target=0 then NULL else Target end


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000