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)
 Building a Case with between function

Author  Topic 

Riklinssen
Starting Member

20 Posts

Posted - 2009-02-18 : 06:11:12
Hello,

I've table with column amount(float), in this table is also an empty column named range. Now I want to say that if amount is between 0 and 250 set column range 0-250, of between 251 and 500 then set column range 251-500 etc. I tried the following but is does not work.
select amount,
case amount when (amount between 0 and 250) then '0 tot 250' end "range"
from tablename

How can I do this.

Thnx in advanced.

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-18 : 06:12:42
[code]select amount,
case when amount between 0 and 250 then '0 tot 250' end as [range]
from tablename[/code]
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-18 : 06:14:08
Also, BETWEEN isn't a function. Its an operator.
Go to Top of Page

Riklinssen
Starting Member

20 Posts

Posted - 2009-02-18 : 07:05:23
Thank you, you were a great help.
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-18 : 07:17:09
np.
Go to Top of Page
   

- Advertisement -