Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
indr4w
Starting Member
27 Posts |
Posted - 2013-07-14 : 22:33:07
|
Hi..all,How to solve divide by zero error when I need to display all records in query?Example:CodeItem QtyOK Target A 50 0B 100 50C 0 50The query should resulting records like this :CodeItem QtyOk Target Percent(QtyOk/Target)A 50 0 0 B 100 50 200C 0 50 0Thank you. |
|
MuMu88
Aged Yak Warrior
549 Posts |
Posted - 2013-07-14 : 22:56:55
|
Try:[CODE]QtyOk / NULLIF(Target,0)[/CODE] |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2013-07-23 : 05:08:00
|
or in General QtyOk / case when Target=0 then NULL else Target endMadhivananFailing to plan is Planning to fail |
|
|
|
|
|