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 |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2009-03-12 : 15:24:01
|
| GreetingsI have the following 4 variables:@length , @width , @gauge , @DensityI need to do the following calculation@length * @width * @gauge * @DensityBut width and gauge could have values of 0Instead of having this huge indented CASE statement how could I do the calculation using boolean validation if @width @gauge are both 0 or if @width or @gauge is zero@length * @width * @gauge * @DensityThank you |
|
|
Bodestone
Starting Member
18 Posts |
Posted - 2009-03-12 : 17:23:46
|
| Not sure exactly what you mean by the boolean validation. Just taking a punt that you want to multiply all the non 0 numbers.Still using case but not nested:SELECT @length * CASE @width WHEN 0 THEN 1 ELSE @width END * CASE @gauge WHEN 0 THEN 1 ELSE @gauge END * @Density |
 |
|
|
|
|
|