Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SQL Order question

513167Mar 12 2007 — edited Mar 12 2007
Dear all,
My table have a field e.g. colA varchar2(2) which stored number. The data stored in this field like that: 88, 89, 90, 91, ...99, 00, 01, 02, ..., 08 etc.
I don't know how to order the number like that: 08, ..., 02, 01, 00, 99 ... , 91, 90, etc.
Any idea?

Thank you!

Regards.

Comments

Aketi Jyuuzou
Is it right?

order by
case when substr(ColA,1,1) = '0' then ColA end desc nulls last,
ColA desc;
513167
Exactly!!!!

Thank you so much!!!! =)

Regards.
martyn

why not just

order by to_number(colA);

edit: I take that back it wont give you 01 before 99..

null

513167
Thank you too. =)

But I have another question, if I have another column (i.e. colB) need to order with the colA, then, what can I do?

Regards.
martyn

just add it at the end, i.e.

ColA desc, 
colB;
513167
Thank you! You solved my problem. =)
1 - 6
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 9 2007
Added on Mar 12 2007
6 comments
1,806 views