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: Optimizing SELECT Query

Re: Optimizing SELECT Query

From: Jason Baugher <jason_at_baugher.pike.il.us>
Date: Thu, 04 Jul 2002 17:08:12 GMT
Message-ID: <Xns92417B75A1750jasonbaugherpikeilus@209.242.76.10>


Daniel Morgan <dmorgan_at_exesolutions.com> wrote in news:3D246E8C.3C0880D6_at_exesolutions.com:

> Carsten Grammes wrote:
>

>> Hello world,
>>
>> following situation: I have a table T with a column C (C are
>> numbers). I want to find the number which is smaller but nearest to a
>> given value N.
>>
>> How to formulate this as a select statement in an efficient way?
>>
>> Thanks,
>> Carsten.
>>
>> ---
>> I want to die peacefully in sleep like my grandfather.
>> Not screaming in terror like his passengers!

>
> It is doable but has ugly written all over it. What is the definition
> of the numeric field? And please let it not be something like
> NUMBER(20,9).
>
> There may be better ways: I hope there are because I would like to
> learn what it is. But my initial instinct would be to create a B*Tree
> using dynamic SQL in a loop.
>
> Daniel Morgan
>
>

Replace N with the value entered:

select max(C) from T where N-C > 0;

Any better ways out there?

-- 
Jason Baugher 
Virtual Adept Professional Consulting Services
1406 Adams St.
Quincy, IL 62301
(217) 221-5406
http://baugher.pike.il.us/virtualadept
jason_at_baugher.pike.il.us
Received on Thu Jul 04 2002 - 12:08:12 CDT

Original text of this message

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