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
 comparing percentages

Author  Topic 

rameshgoudd
Starting Member

13 Posts

Posted - 2008-03-17 : 01:46:50
hi

i have a three fields in my table..those are


FromPercentage -Varchar(30)
ToPercentage -Varchar(30)
Scale -Int(11)

i have the percenatge that 10%...now i want to check that whether this 10 % is in between the frompercentage and topercentage..if it is there i want to return the the scale value..how can i do this in sql.

i know comparing when it is integer using where and and operator..but i dont know how use if it has the percentages.


Ram

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-03-17 : 05:33:40
You should have used int datatype to store percentage values

Try

Select scale from your_table
where cast(replace(@your_input,',','') as int) between cast(replace(FromPercentage ,',','') as int) and cast(replace(toPercentage,',','') as int)

Madhivanan

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

- Advertisement -