🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.opensource
Article #126

Re: Is there something equivalent to a "Find nearest" in SQL, IB6.0.2.0?

#126
From: Michael Adamovic
Date: Tue, 09 Aug 2005 13:23
51 lines
2379 bytes
Hi Red,

you can use the following :

select fld_1-2.99999999,fld_2 from table1 where fld_1-2.99999999 > 0
order by 1

select fld_1-2.99999999,fld_2 from table1 where fld_1-2.99999999 < 0
order by 1 DESC

In the first row of seach select you find the value with the minimum 
deviation, in the first one the minimum positive deviation and in the second 
one the minium negative deviation.

Hope that helps

Mike

"Red" <nospam_kandw321@icrossroads.com> schrieb im Newsbeitrag 
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...

I hope this illustrates my problem.

Thanks for your help.
Technical Details
Message-ID: <42f8ae6f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!pd7cy1no!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <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
Reply-To: "Michael Adamovic" <michael.adamovicNO@abstSPAMhessen.de>
From: "Michael Adamovic" <michael.adamovicNO@abstSPAMhessen.de>
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, 9 Aug 2005 15:23:35 +0200
Lines: 54
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
NNTP-Posting-Host: 62.138.187.210
Message-ID: <42f8ae6f$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1123593839 62.138.187.210 (9 Aug 2005 06:23:59 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!newshub.sdsu.edu!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!pd7cy1no!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail