Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL-Select Command

Status
Not open for further replies.

Deathsbain

Programmer
Sep 17, 2007
3
US
this is the situation --

i am creating a user defined function...

have a table with highvalue, lowvalue, percent fields.

will be passing in a value and need to get the percent field from a "between" the high/low values...

ok that works fine except one thing... what happens if there is a gap in the values? like say i have one record low=13, high=14, other record is low=16, high=17, and the value passed is 15....

is there a way to make it select the record information that has the highvalue that is closest (lower) to it? and how would i go about that?

please... any and all help would be appreciated.


Deathsbain -- have you hugged your undertaker today?
 
Code:
SELECT ...
FROM YourTable 
WHERE @ParameterPassed BETWEEN LowValue AND HighValue

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
yes... i have that part... but how do i deal with the gaps? like i said...

record1 = low-14/high-15/percent-15
record2 = low-17/high-18/percent-25
record3 = low-13/high-14/percent-05
record4 = low-18/high-19/percent-35

passedvalue = 16....

what i need it to do is if it fails to find one that it matches select the nearest (on "highvalue" that is less than it is) record.

Thanks a million for all your help!!!


Deathsbain - Have you hugged your undertaker today???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top