Thursday, June 23, 2016

Netezza: Split delimited string how to

Split delimited string using Netezza SQL Extensions Toolkit

Also see post how to JOIN or concatenate string:  Netezza: concatenate rows into string with XMLAGG()




Alternative 1
Using ARRAY_SPLIT function that strips off a delimiter. 

select SQL_EXTENSIONS..ARRAY_COMBINE(
              SQL_EXTENSIONS..ARRAY_SPLIT( '1,2,3,,,4,5,abc,mama,al123num,',',' )
          , '|'
);




Alternative 2:
Using regexp_extract_all function that preserves the delimiter. 

select SQL_EXTENSIONS..array_combine(
            SQL_EXTENSIONS..regexp_extract_all( '1,2,3,,,4,5,abc,mama,al123num,', '.*?,')
                      , '|'
);




No comments:

Post a Comment