I have a table like this:
To_day | percent
-----------------------
5 | 1.5
8 | 2
2147483647 | 3
I want to write a SELECT that take a day, find fitted range in To_day column and give back Related percent. for example:
@day = 3 -------> percent = 1.5
@day = 5 -------> percent = 1.5
@day = 7 -------> percent = 2
@day = 15 ------> percent = 3
Try this:
SELECT TOP 1 [percent]
FROM mytable
WHERE To_day >= @d
ORDER BY to_day
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With