Article View: borland.public.interbase.opensource
Article #252Re: Is there something equivalent to a "Find nearest" in SQL, IB6.0.2.0?
From: Dan Palley
Date: Tue, 17 May 2005 22:16
Date: Tue, 17 May 2005 22:16
40 lines
2179 bytes
2179 bytes
"Red" <nospam_kandw321@icrossroads.com> wrote in message news:428a630b.73020187@newsgroups.borland.com... > On Tue, 17 May 2005 23:23:52 +0200, Aage Johansen > <aagjohan@offline.no> wrote: > >>b.p.i.general and b.p.i.sql (and others) are open, IB/6 is OnTopic >>(AFAIU), and with healthy traffic. > > Thanks. I've added them to my "subscribed" list. > >>As for your question, could you give some examples of what you want. >> > > > In the database there are 6 records as follows > > fld_1, fld_2 > > 2.33468761, 8 > 2.87764586, 3 > 3.00177652, 5 > 3.20464536, 9 > 3.29676754, 2 > > Value to lookup in fld_1: 2.99999999 > > Nearest single record would be: 3.00177652, 5 > > I would grab the five, and continue with my next task... There's no slick way to do this in SQL. The best thing I can think of would be to do something like this: Select * from table1 where fld_1 <=2.99999999 order by fld_1 desc rows 1 and Select * from table1 where fld_1>=2.9999999 order by fld_1 asc rows 1 Dan
Technical Details
Message-ID:
<428a6d3e$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<428a5b61.71058216@newsgroups.borland.com> <428a60f3$1@newsgroups.borland.com> <428a630b.73020187@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 106772,8899b8536c5e6b11 X-Google-Attributes: gid106772,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Dan Palley" <dan@trams.com> Newsgroups: borland.public.interbase.opensource References: <428a5b61.71058216@newsgroups.borland.com> <428a60f3$1@newsgroups.borland.com> <428a630b.73020187@newsgroups.borland.com> Subject: Re: Is there something equivalent to a "Find nearest" in SQL, IB6.0.2.0? Date: Tue, 17 May 2005 15:16:32 -0700 Lines: 42 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 157.238.54.69 Message-ID: <428a6d3e$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1116368190 157.238.54.69 (17 May 2005 15:16:30 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail