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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 comparison of two columns with minimum diff

Author  Topic 

mauich123
Starting Member

21 Posts

Posted - 2011-01-18 : 04:40:29
Hi

I have a question regarding comparison. I want to compare two float columns with eachother using a WHERE-clause that specifies a value that is the minimum amount of difference in the comparison

For example if this value = 2
10,01 and 10 would not be selected although
12,50 and 10 would be

How would such a where-clause look like?
Thanks! :)

chris_cs
Posting Yak Master

223 Posts

Posted - 2011-01-18 : 05:31:47
You could probably just use:

WHERE value1 - value2 >= 2
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-01-18 : 06:44:45
Depending on how your data is structured, you may need to use absolute value, as in:
where abs(value1 - value) >= 2.0
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-18 : 08:45:11
If the above codes do not work, post some sample data with expected result

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -