‎2006 Mar 02 4:02 PM
Hello,
I need to pick up a value from a table which is closest to another value.
For eg i need to pick up a qty ie closest to 6 and not equal to 6.
It might be 5 or 7.(which ever closest is available)
is there any other way to give a where condition than the not equal to....?
thanks,
Larry
‎2006 Mar 02 4:05 PM
You can try this -
Get all the data into internal table. Loop at the internal table and check the condition for the specified field.
‎2006 Mar 02 4:11 PM
Hi
U can use round and trnacate function.
suppose u have value 4.5 take to value
4 and 5 use <b>BETWEEN</b> condition in where condition.
this may be useful.
regards
vinod
‎2006 Mar 02 4:11 PM
Hi
I don't think, you need to load all data and then control which is the closest value, something like following code:
CHECK_VALUE = 6.
SELECT * FROM <TABLE> WHERE ......
DELTA = ABS( <TABLE>-QTY - CHECK_VALUE ).
IF DELTA < DELTA_OLD.
DELTA_OLD = DELTA.
OK_QTY = <TABLE>-QTY.
ENDIF.
ENDSELECT.
Max
‎2006 Mar 02 4:16 PM
Max,
will it not be good to do this processing using internal tables rather than in SELECT - ENDSELECT.
We can define lower range and higher range. And delete data from internal table which does not fall in this criteria. (< lower range and > higher range)
ashish
Message was edited by: Ashish Gundawar
‎2006 Mar 02 4:20 PM
Hi
Yes of course!
I wrote only an example to explain the logic.
Max
‎2006 Mar 02 4:29 PM