Reputation: 457
I have table name tblRate
in that two columns are their TotalDays
and Rate
values in table e.g
TotalDays | Rates
20 | 3.5
30 | 4.5
40 | 5.5
I want to write query that will return rate if I provide value of total days i.e if i provide values as 35 then it needs to be return the value of 4.5 that means 4.5 is come in between the 30 to 40 range.
Upvotes: 2
Views: 74
Reputation: 424993
Try this:
select max(rate) as rate
from tblRate
where TotalDays <= ?
Where ?
!is your value.
This will work if rates
increases with TotalDays
, which it seems to do.
Upvotes: 1
Reputation: 35780
If I got right:
select * from rates where totaldays = (@v / 10)*10
Or:
select top 1 * from rates where totaldays <= @v order by totaldays desc
Upvotes: 4