I need to separate the value of a column by commas.
Example: BCDEY; I need to convert to a B, C, D, E, Y.
Follows the "select":
SELECT CDGRUPOCONDICAO FROM TBINTCLIENTE;
You can try also this:
with cad as
(select 'BCDEY' cad from dual)
select regexp_replace (regexp_replace(cad,'(.)','\1, '),', $','') cad_comma from cad;
Something like that maybe?
with testdata as (select 'BCDEY' str from dual)
select listagg(c, ', ') within group(order by lvl)
from (
select substr(str, level, 1) c,
level lvl
from testdata
connect by level <= length(str)
)
Producing:
B, C, D, E, Y
Here, the subquery split the string character by character. Then the outer listagg re-assemble the items by joining them with ', '.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With