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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-05-21 : 09:13:36
|
| Ruth writes "I'm trying to divide on column by another in a T-SQL statement and would like to perform the division only if the denominator is not = 0. I would like to retain the records where the denominator is 0, otherwise I would use a where clause.In MS Access I've used the iif statement as in: iif(denominator <> 0,numerator/denominator,0) Can you tell me how I would go about doing this in T-SQL?Thanks very much for your help." |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-05-21 : 09:23:55
|
| SELECT CASE denominatorWHEN 0 THEN 0ELSE numerator/denominatorENDTake a look in Books Online for more information about the CASE expression. |
 |
|
|
|
|
|