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 the words distinct in ascending order from the column

Sid_ Z.Dec 19 2023

Hi All,

Oracle version - 19c

Three distinct values for the given column are - ‘MET’ ‘MET_LATE’ ‘PARTIALLY_MET’

And these can appear many times in the column as shown in the sample data.

We just need to sort them in ascending order with distinctly. Sample data is as below:

with test_data as
( Select 'MET MET_LATE PARTIALLY_MET MET_LATE MET' as text from dual union all
Select 'MET_LATE PARTIALLY_MET MET_LATE MET MET' from dual union all
Select 'PARTIALLY_MET MET_LATE ' from dual  union all
Select 'MET PARTIALLY_MET MET'  as data from dual 
)
select text from test_data;
Expected Output:
MET MET_LATE PARTIALLY_MET
MET MET_LATE PARTIALLY_MET
MET_LATE PARTIALLY_MET
MET PARTIALLY_MET

Regards,

Sid

This post has been answered by mathguy on Dec 19 2023
Jump to Answer
Comments
Post Details
Added on Dec 19 2023
18 comments
432 views