List:General Discussion« Previous MessageNext Message »
From:Lee Goddard Date:August 3 2006 7:27pm
Subject:Re: Finding the closest value
View as plain text  
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)),
>               LEAST( ABS(MIN(@n-col2)),
>                      ABS(MIN(@n-col3))
>                    )
>             )
> FROM ...
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?

Thanks in anticipation

Finding the closest valueLee Goddard31 Jul
  • Re: Finding the closest valuePeter Brawley31 Jul
    • Re: Finding the closest valueLee Goddard3 Aug
      • Re: Finding the closest valuePeter Brawley4 Aug