Write query to convert string in ascending order
Input:
ORACLE
Output:
ACELOR
STEP1:
with d as (select 'ORACLE' c FROM DUAL)
select c from d
connect by level<=length(c);
Output:
ORACLE
ORACLE
ORACLE
ORACLE
ORACLE
ORACLE
STEP2:
with d as (select 'ORACLE' c FROM DUAL)
select substr(c,level,1) e from d
connect by level<=length(c);
Output:
O
R
A
C
L
E
STEP3:
with d as (select 'ORACLE' c FROM DUAL)
select listagg(e,'') within group(order by e asc) col
from (select substr(c,level,1) e from d
connect by level<=length(c));
Output:
ACELOR
No comments:
Post a Comment