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!

How to sort table based on parameters?

Steve42Sep 17 2013 — edited Sep 18 2013

Here is a sample. I want the table to be sorted on the input parameters (20,40,30,10).

Drop table dummy;

create table dummy(aname varchar2(20)

,acode number(4,0));

insert into dummy(aname,acode) values ('Wyoming',30);

insert into dummy(aname,acode) values ('Texas',10);

insert into dummy(aname,acode) values ('Iowa',40);

insert into dummy(aname,acode) values ('Kansas',20);

commit;

Select acode, aname

from dummy

where acode in (20,40,30,10);

I want the output to be sorted by the (20,40,30,10) - this input could have more numbers than these 4 and look like this:

20, Kansas

40, Iowa

30, Wyoming

10, Texas

Suggestions?

TIA

Shall42

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 16 2013
Added on Sep 17 2013
6 comments
451 views