Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: finding a number with smalles difference
"dave" <davidkargl_at_yahoo.de> a écrit dans le message de
news:b7ac8202.0503290721.be65186_at_posting.google.com...
| 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
Have a look at lag and lead analytic functions:
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions56a.htm#83619 http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions60a.htm#83836 http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions2a.htm#81409
Regards
Michel Cadot
Received on Tue Mar 29 2005 - 09:58:58 CST