Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: finding a number with smalles difference

Re: finding a number with smalles difference

From: <ken_at_kendenny.com>
Date: 29 Mar 2005 10:12:56 -0800
Message-ID: <1112119976.482670.316870@f14g2000cwb.googlegroups.com>


dave wrote:
> hi!
> i`m writing on a procedures to rebook hotel-reservations.
> to do that, i have to find a category with the nearest price to the
> existing booking.
>
> e.g.:
> table: cat (id, desc, price)
> 1 "foo" 10
> 2 "bar" 20
> 3 "non" 40
> 4 "dog" 50
> 5 "xes" 50
>
> the existing booking has cat.id 2, that means the category with the
> nearest price would be cat#1. if cat.id was 3, the category with the
> nearest price would be cat#4. case cat.id = 4 result should be cat#5.
> (same price)
>
>
> in other words: the problem is to find a number (higher or lower)
with
> the smalles (or no) diffence to the give number.
>
>
> so is there an operator like "like" for numbers?
> can anybody give me a hint?
> SELECT id FROM cat WHERE...?
>
> thx in advance, dave

Hint: the ABS function. Received on Tue Mar 29 2005 - 12:12:56 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US