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
 Search in between

Author  Topic 

Apples
Posting Yak Master

146 Posts

Posted - 2008-02-07 : 16:38:59
Here's my table:

---------------------
Policies | Premiums
---------------------
10000 | 229
10500 | 233
11000 | 235
11500 | 239
...and so on...

The user enters a policy amount, and based on that amount, it gives the premium amount. The way it works is if they enter a number in between the policies, say 11300, it will give the next highest premium, which would be 239 in that case.

How can I implement that procedure? I thought about just incrementing the user input until it is found, but that could get very tedious.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-02-07 : 16:45:09
how about:

select min(premiums) from <table> where Policies >= @p

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -