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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 between

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-12-05 : 09:51:05
Not sure why null is returned where I can see in the table that there is indeed data.

declare @tblData table(price decimal(12, 8), size decimal(12, 8))

insert @tblData
select 113.93000000, 2.00000000 union all
select 114.12500000, 2.00000000 union all
select 114.06300000, 2.00000000 union all
select NULL, NULL union all
select 114.06200000, 2.00000000 union all
select NULL, NULL

select sum(Size) from @tbldata
where Price between 114.12500000 and 114.12500000 - 0.01

WHEREAS this does return data but seems to be incorrect
declare @tblData table(price decimal(12, 8), size decimal(12, 8))

insert @tblData
select 114.18000000, 2.00000000 union all
select NULL, NULL union all
select 114.18800000, 2.00000000 union all
select 114.18750000, 2.00000000 union all
select 114.18700000, 2.00000000 union all
select 114.18700000, 2.00000000

select sum(Size) from @tbldata
where Price between 114.18700000 and 114.18700000 + 0.01

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-05 : 09:53:52
OMG!

Didn't you see my last reply here?
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=93715

BETWEEN needs first value to be smaller/lesser/earlier than second value.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2007-12-05 : 09:59:02
I see.
Thanks again
Go to Top of Page
   

- Advertisement -