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: Complex ORDER BY clauses

Re: Complex ORDER BY clauses

From: Jonathan Gennick <jonathan_at_gennick.com>
Date: Sun, 16 Nov 2003 00:34:55 -0500
Message-ID: <1v2ervotrgtg6k4jkdd49mfuqtft7rg9oc@4ax.com>


On Sun, 16 Nov 2003 00:08:21 -0500, Jonathan Gennick <jonathan_at_gennick.com> wrote:

>An interesting twist on this problem would be to sort B and E first,
>and then everything else in alphabetical order.

Ah, I just had a thought. Try this:

SELECT test_col
FROM t
ORDER BY DECODE(test_col,'B',1,'E',2,99), test_col;

The first DECODE ensures that B and E sort first. The first sort key for all other letters will be 99. The secondary sort key doesn't matter for B and E, since those letters will be the only ones in their respective groups. All other letters will lfall into the 99 group, and they'll be sorted in order.

Jonathan Gennick --- Brighten the corner where you are http://Gennick.com

Join the Oracle-article list and receive one article on Oracle technologies per month by email. To join, visit http://four.pairlist.net/mailman/listinfo/oracle-article, or send email to Oracle-article-request_at_gennick.com and include the word "subscribe" in either the subject or body. Received on Sat Nov 15 2003 - 23:34:55 CST

Original text of this message

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