-
May 4th, 2015, 02:41 AM
#1
get nearest or closest values
In the access data table there are two fields:-
name Value
GS402 300
GS632 600
GS802 1000
GS100 2000
GS101 2000
GS121 4000
GS125 4000
GS160 8000
GS161 8000
GS201 16000
GS200 16000
GS250 32000
GS251 23600
I am using Vb6 and access 2010 database
if i get value 4800 then
what query i should write in vb to get nearest or closest values of 4800 from the above table
Please help me to to get the query
Last edited by suraj14; May 4th, 2015 at 02:44 AM.
-
May 6th, 2015, 07:32 PM
#2
Re: get nearest or closest values
Query Analyzer should convert it to SQL for you. Try it out!
-
May 7th, 2015, 12:10 AM
#3
Re: get nearest or closest values
Off the top of my head I would think this may be a case for a union
http://www.w3schools.com/sql/sql_union.asp
You could use that to execute two queries one to find the next highest value and the other to find the next lowest value and then compare those two values to your target value to see which is closest.
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|