Re: Please help with SQL
Posted in 1996
Douglas Wilson — — source: Informix-list mailing list archive (1991-1998)
Jonathan Leffler wrote:
>
> 1. SELECT *
> FROM tab1 A
> WHERE koef = (SELECT koef FROM tab1 B GROUP BY koef HAVING MIN(ABS(keyval-koef)));
>
> I've not tested this for syntax or semantics
The above returns a syntax error.
How about:
select *
from tab1
where abs(koef-?) in
(select min(abs(koef-?)) from tab1)
which still might return more than 1 row, and won't take advantage of
any existing index, so depending on the size of the table, my first
answer may still be better.
Sincerely,
Douglas Wilson
*** Disclaimer: These are the opinions of the poster not Amgen Inc.***