Subject Re: Getting the 'closest' return
Author dleec45
Thanks Steffen for the reply. I get and function unknown error on ABS
when I try to use the query. I'm using this against a table of zip
codes and here's what I have:

select * from storezips a where a.minorzip in
( select first 1 b.minorzip from storezips b order by abs(b.minorzips
- 53000) asc )

Did I mess it up in my translation? Lee


> Hi
>
> select * from table a where a.field in
> ( select first 1 b.field from table b order by abs(b.field - ?) asc )
>
> Regards,
> Steffen
>
> -----Original Message-----
> From: dleec45 [mailto:dleec45@n...]
> Sent: Wednesday, June 09, 2004 5:44 AM
> To: firebird-support@yahoogroups.com
> Subject: [firebird-support] Getting the 'closest' return
>
> How do I write a query which will return the closest value in the where
> statement. If I have a bunch of numbers in a table that has values like
> 100, 200, 300, 400 and my where clause looks for 249 or 250, how do
I return
> 200 or 200 and 300, whatever the case may be?
>
>
>
> ------------------------ Yahoo! Groups Sponsor
--------------------~--> Make
> a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
> Now with Pop-Up Blocker. Get it for free!
> http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/67folB/TM
> --------------------------------------------------------------------~->
>
>
> Yahoo! Groups Links