Click here to Skip to main content
15,905,967 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am storing ranges in sql database like following,

Start     End        Percentage
-----     ----      -------------
10         20          1
500        860         5
1000       2500        10



the above shown is the database design

Now the question is,

When I pass 15,then I need to get the percenatge as 1,
means

find the range where 15 occurs and get the percentage of that range

here 15 exists between 10 and 20 and corresponding percentage is 1.


Any help will be gratefull

Thanks
Posted
Comments
Thanks7872 14-Oct-13 1:49am    
And? Where is the code you have tried? Post it and also mention why its not working or whats the problem with that code?
JoCodes 14-Oct-13 2:03am    
"find the range where 15 occurs and get the percentage of that range
here 15 exists between 10 and 20 and corresponding percentage is 1" ?? not clear at all
kishore Rajendran 14-Oct-13 2:09am    
I will pass 15, so I have find the range where this 15 occurs, here it is 10 and 20
thats all

1 solution

Try:
SELECT percentage WHERE value BETWEEN [Start] AND [End]
 
Share this answer
 
Comments
kishore Rajendran 14-Oct-13 1:55am    
but I have only one value to pass,that is 15
OriginalGriff 14-Oct-13 2:02am    
So replace the word "value" withe value "15"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900