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

Home -> Community -> Usenet -> c.d.o.server -> Re: cusotm sort in order by

Re: cusotm sort in order by

From: Michel Cadot <micadot_at_altern.org>
Date: Tue, 3 Aug 1999 15:22:47 +0200
Message-ID: <7o6qg5$3gq$1@oceanite.cybercable.fr>


Kenneth is right. Therefore you can create a function to perform the order:

create function my_order (b T.B%type) return integer (or varchar2 or...) as
begin

    <here the code that returns a number (or...) for the value of the column B       for instance, the decode shows in the answer sends by chensm> end;
/

Then you can select ordering with that function:

select * from t order by my_order(b);

If *you* know how to perform the order, you can write the code. Hope this helps you.

Kenneth C Stahl a écrit dans le message <37A6DF87.71E5BD1F_at_Unforgettable.com>...
>That isn't a sort. The term 'sort' implies collation by pre-defined
>order. Typically this is canonically in alphabetic order. Your example
>doesn't provide any explanation for how you arrived at your
>non-alphabetic order. Therefore it is impossible to derive an algorithm
>whereby the data ordering can be performed.
>
>Nandakumar wrote:
>
>> I like to sort the rows of a table in a custom order of a column.
>> Say the table T(A,B) has values for B as
>> 'Snake' 'Dog', 'Horse', 'Elephant'.
>> I would want the select to list the values in the order
>> 'Dog' 'Hosrse' 'Snake' 'Elephant'. (** Not in ASC or DESC orders)
>>
>> Would appreciate any help.
>> --
>> Nandakumar
>> Systems Analyst
>> New York
>> (N.Kumar_at_rocketmail.com)
>>
>> Sent via Deja.com http://www.deja.com/
>> Share what you know. Learn what you don't.
>
Received on Tue Aug 03 1999 - 08:22:47 CDT

Original text of this message

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