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 |
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2004-10-21 : 10:40:01
|
| In one of my rows cost and sales are both equal to 0, so the query returns an error. What can I do to correct this?SELECT ((cost / sales) * 100) As percentprofitFROM squareinch |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-10-21 : 10:52:53
|
| SELECT CASE WHEN COALESCE(sales, 0) = 0 THEN NULL ELSE ((cost / sales) * 100) END As percentprofitFROM squareinchKrsiten |
 |
|
|
jrockfl
Posting Yak Master
223 Posts |
Posted - 2004-10-21 : 11:16:56
|
| Perfect! Thank you!! |
 |
|
|
|
|
|