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!

decode in order by - asc/desc

416760Mar 15 2004 — edited Mar 24 2004
I'm trying to be able to dynamically change the asc/desc in the order by.

Here is some sql that works:
select * from transactions order by decode(somevar,'a',acct_nbr,'c',card_number,acct_nbr) asc

What I wanted was something like this:
select * from transactions order by decode(somevar,'a',acct_nbr,'c',card_number,acct_nbr) decode(anothervar,'a',asc,'d',desc,asc)

but this doesn't appear to work. Am I missing something, or is there another way.

Thanks in advance,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 21 2004
Added on Mar 15 2004
9 comments
717 views