Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Complex ORDER BY clauses
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