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 |
thanksfor help
Posting Yak Master
106 Posts |
Posted - 2007-08-02 : 15:03:18
|
Hi,I have following situationdeclare @a decimal(18,0)declare @b decimal(18,0)declare @c decimal(18,2)set @a = 2set @b = 2set @c = 0select case when ((@a - @b) > @c) then 0 endIn the case when @a and @b have the same value, I get the answer NULL and not 0. Please advice what I am doing wrong here. I need to get the value 0.Any help is very much appreciated. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-08-02 : 15:08:12
|
select case when ((@a - @b) >= @c) then 0 endTara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-08-02 : 15:08:27
|
select case when ((@a - @b) > @c) then 0 else 0 end_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-08-02 : 15:08:42
|
_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
thanksfor help
Posting Yak Master
106 Posts |
Posted - 2007-08-02 : 15:14:50
|
thank youuuuuuuuuuuuuuuuuu very much, >= did the magic |
 |
|
Jim77
Constraint Violating Yak Guru
440 Posts |
Posted - 2007-08-06 : 11:55:49
|
why wouldnt you use the isnull function here ? |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-08-06 : 12:17:18
|
quote: Originally posted by Jim77 why wouldnt you use the isnull function here ?
It's not needed. The CASE was simply missing an ELSE clause, causing NULLS to be returned.- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
|
|