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!

Sort Columns

addiebeeAug 7 2019 — edited Aug 7 2019

Hi,

Create table tbl_charges

(

     center int,

     fe_currency varchar2(5),

     front_end_chg number,

     be_currency varchar2(5),

     backend_chg number

);

insert into tbl_charges value (123,'USD', 1.25, 'SGD', 5);

insert into tbl_charges value (123,'USD', 1.25, 'USD', 5);

insert into tbl_charges value (123,'USD', 1.25, 'SGD', 5);

insert into tbl_charges value (123,'PHP', 1.25, 'USD', 5);

insert into tbl_charges value (123,'USD', 1.25, 'YEN', 5);

insert into tbl_charges value (456,'WON', 1.25, 'YEN', 5);

insert into tbl_charges value (456,'USD', 1.25, 'USD', 5);

insert into tbl_charges value (456,'USD', 1.25, 'SGD', 5);

insert into tbl_charges value (911,'PHP', 1.25, 'USD', 5);

insert into tbl_charges value (911,'USD', 1.25, 'YEN', 5);

insert into tbl_charges value (911,'WON', 1.25, 'USD', 5);

So I have a table named tbl_charges as seen in the table below and it has columns center, fe_currency, front_end_chg, be_currency, and backend_chg. And I wanted to order the data by center, fe_currency, and be_currency. Is it possible to order the data by center and fe_currency and center and be_currency without affecting the order of the fe_currency? See sample table below for my expected output.

SAMPLE TABLE:

CENTER
FE_CURRENCYFRONT_ENT_CHGBE_CURRENCYBACKEND_CHG
123USD1.25SGD5
123USD1.25USD5
123USD1.25SGD5
123PHP1.25USD5
123USD1.25YEN5
456WON1.25YEN5
456USD1.25USD5
456USD1.25SGD5
911

PHP

1.25USD5
911USD1.25YEN5
911WON1.25USD5

EXPECTED OUTPUT

CENTERFE_CURRENCYFRONT_ENT_CHGBE_CURRENCYBACKEND_CHG
123PHP1.25SGD5
123USD1.25SGD5
123USD1.25USD5
123USD1.25USD5
123USD1.25YEN5
456USD1.25SGD5
456USD1.25USD5
465WON1.25YEN5
911PHP1.25USD5
911USD1.25USD5
911WON1.25YEN5

I appreciate the effort and help. Thank you!

Comments
Post Details
Added on Aug 7 2019
8 comments
269 views