Re: [pgsql-advocacy] Function which gives back the nearest neighbours

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Virgile Beddok <virgile(dot)beddok(at)igd(dot)fraunhofer(dot)de>
Cc: pgsql-novice(at)postgresql(dot)org, pgsql-advocacy(at)postgresql(dot)org, pgsql-admin(at)postgresql(dot)org
Subject: Re: [pgsql-advocacy] Function which gives back the nearest neighbours
Date: 2005-03-27 05:24:34
Message-ID: 42464392.9040903@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-advocacy pgsql-novice

> I'm looking for an existing function which allows me to search the nearest
> neighbours of the requested value.

Well you could try something like:

SELECT * FROM table ORDER BY ABS(val - 2) LIMIT 1;

That doesn't get you all the way there, but it's an idea...

Chris

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Michael Fuhr 2005-03-27 06:52:43 Re: Question about trace session
Previous Message Joe Halpin 2005-03-26 21:50:08 Problem setting runpath

Browse pgsql-advocacy by date

  From Date Subject
Next Message Robert Bernier 2005-03-27 14:52:52 Re: postgresQL.org "Latest News" or "Latest Product"?
Previous Message Virgile Beddok 2005-03-25 18:36:16 Function which gives back the nearest neighbours of a requested value

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2005-03-27 15:54:31 Re: I'd Like To See Permissions Granted
Previous Message Stephen Choularton 2005-03-26 23:13:59 initial password