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 |
|
tantcu
Yak Posting Veteran
58 Posts |
Posted - 2012-07-13 : 09:16:25
|
| Hello,I have some data and it contains value 0 on it. When I set up the formula for example, cogs/sales. Because there are some sales with 0 value so that the query I set up with formula does not work when you divide something with the 0. Do you know how to fix that problem? |
|
|
singularity
Posting Yak Master
153 Posts |
Posted - 2012-07-13 : 09:21:54
|
Instead of doing cogs/sales, you can do:case when sales = 0 then 0 else cogs/sales end |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-13 : 09:57:38
|
| or coalesce(cogs/nullif(sales,0),0)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|