Answered by:
How to compare the decimal?

Question
-
hi,experts,help me please,
declare @t table(id int,value decimal(18,2)) insert into @t select 1,10.22 union select 2,200.00 select * from @t where value<7.5
return null, if i run:
select * from @t where value<'7.5'
also return null, how to compare the decimal column?Thanks.Regards
Garey
Wednesday, June 29, 2011 11:01 AM
Answers
-
I got both NULLs,looks like 10.22 and 200 is greater than 7.5 :-) No?
declare @t table(id int,[value] decimal(18,2))
insert into @t
select 1,10.22 union
select 2,200.00
select * from @t where [value]<7.5
--return null, if i run:
select * from @t where [value]<'7.5'
Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/Wednesday, June 29, 2011 11:04 AMAnswerer -
Your query is right, try to reverse >
declare @t table(id int,value decimal(18,2)) insert into @t select 1,10.22 union select 2,200.00 select * from @t where value>7.5 --1 10.22 --2 200.00
Best regards- Proposed as answer by RaheelKhan Wednesday, June 29, 2011 2:20 PM
- Marked as answer by Old Garey Thursday, June 30, 2011 1:28 AM
Wednesday, June 29, 2011 11:04 AM -
I add other value to the table and it works :
declare @t table(id int,value decimal(18,2)) insert into @t select 1,10.22 union select 2,200.00 union select 3,6.5 select * from @t where value<7.5 --1 6.50
Best regards- Marked as answer by Old Garey Thursday, June 30, 2011 1:28 AM
Wednesday, June 29, 2011 11:07 AM -
hi,experts,help me please,
declare @t table(id int,value decimal(18,2)) insert into @t select 1,10.22 union select 2,200.00 select * from @t where value<7.5
return null, if i run:
select * from @t where value<'7.5'
also return null, how to compare the decimal column?Thanks.Regards
Garey
Please check your condition ......... :)110.22 and 2200.00 values are not less then "<" of value 7.5
thanks,
Muhammad Azeem- Proposed as answer by RaheelKhan Wednesday, June 29, 2011 2:20 PM
- Marked as answer by Old Garey Thursday, June 30, 2011 1:28 AM
Wednesday, June 29, 2011 11:12 AM
All replies
-
I got both NULLs,looks like 10.22 and 200 is greater than 7.5 :-) No?
declare @t table(id int,[value] decimal(18,2))
insert into @t
select 1,10.22 union
select 2,200.00
select * from @t where [value]<7.5
--return null, if i run:
select * from @t where [value]<'7.5'
Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/Wednesday, June 29, 2011 11:04 AMAnswerer -
Your query is right, try to reverse >
declare @t table(id int,value decimal(18,2)) insert into @t select 1,10.22 union select 2,200.00 select * from @t where value>7.5 --1 10.22 --2 200.00
Best regards- Proposed as answer by RaheelKhan Wednesday, June 29, 2011 2:20 PM
- Marked as answer by Old Garey Thursday, June 30, 2011 1:28 AM
Wednesday, June 29, 2011 11:04 AM -
I add other value to the table and it works :
declare @t table(id int,value decimal(18,2)) insert into @t select 1,10.22 union select 2,200.00 union select 3,6.5 select * from @t where value<7.5 --1 6.50
Best regards- Marked as answer by Old Garey Thursday, June 30, 2011 1:28 AM
Wednesday, June 29, 2011 11:07 AM -
hi,experts,help me please,
declare @t table(id int,value decimal(18,2)) insert into @t select 1,10.22 union select 2,200.00 select * from @t where value<7.5
return null, if i run:
select * from @t where value<'7.5'
also return null, how to compare the decimal column?Thanks.Regards
Garey
Please check your condition ......... :)110.22 and 2200.00 values are not less then "<" of value 7.5
thanks,
Muhammad Azeem- Proposed as answer by RaheelKhan Wednesday, June 29, 2011 2:20 PM
- Marked as answer by Old Garey Thursday, June 30, 2011 1:28 AM
Wednesday, June 29, 2011 11:12 AM -
Sorry, toooooo tired,:) must take leave to relex. Thanks all.
Regards
Garey
Thursday, June 30, 2011 1:28 AM