Re: Finding nearest numeric value

From: Poul Møller Hansen <freebsd(at)pbnet(dot)dk>
To: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Finding nearest numeric value
Date: 2005-08-17 14:01:04
Message-ID: 43034320.2040900@pbnet.dk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


>To find the nearest value in number_column to some CONSTANT (where you
>replace constant with a number), try:
>
>select *,(number_column - CONSTANT)^2 as d from tablename order by d limit
>1;
>
>Does that do it for you?
>
>Sean
>
>
It does ideed, not that I understood how, but I will find out.
Thank you very much.

Poul

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Csaba Nagy 2005-08-17 14:27:50 Re: Finding nearest numeric value
Previous Message Sean Davis 2005-08-17 13:39:20 Re: Finding nearest numeric value