Re: Finding the closest value

2006-08-03 Thread Peter Brawley
Lee >I think the formula is just right - very clever. But is it possible to make >sure that col1, col2 and col3 are all from the same record? Different question, different answer I ween  :-) SET @n = ; SELECT   id,   MIN( LEAST( ABS(@n-col1), LEAST( ABS(@n-col2), ABS(@n-cl3) ))) AS min F

Re: Finding the closest value

2006-08-03 Thread Lee Goddard
Peter Brawley wrote: />Is there an efficient way to find the closest numerical value, across >three columns? I do not know if there is a way to find it across one. / Not sure about efficiency, but if the criterion number is @n, do you mean ... SELECT LEAST( ABS(MIN(@n-col1)), LE

Re: Finding the closest value

2006-07-31 Thread Peter Brawley
>Is there an efficient way to find the closest numerical value, across >three columns? I do not know if there is a way to find it across one. Not sure about efficiency, but if the criterion number is @n, do you mean ... SELECT LEAST( ABS(MIN(@n-col1)),   LEAST( ABS(MIN(@n-col2))