需求:一串字母'ADFGH',需要按照顺序来显示:A D F G H
第一步:先把字符串拆分
with test as( select 'ADFGH' as a from dual ) select a ,substr(a,level,1) from test connect by level<=length(a)
第二步:用listagg拼接
with test as( select 'ADFGH' as a from dual ) select a ,(select listagg(substr(a,level,1),',') witnin group (order by substr(a,level,1)) from dual connect by level<=length(a)) b from test