How to split multiple values from a row into separate rows?

前端 未结 2 895
我寻月下人不归
我寻月下人不归 2021-01-25 08:57

I want to split multiple values from a row into a separate row in sap hana sql. table :

 id  name
 1   kabil,arasan

but I want

2条回答
  •  长发绾君心
    2021-01-25 09:14

    Slight tweaking of the use of the SUBSTR_REGEXPR function. I've used this just last week in Hana as a Script_View and can confirm it works.

    Begin
    VAR_OUT =
        select *
        from ( select
        ST.PARAM, -- Source table id
        NT.Element_Number, -- Occurrence number within source table row
    SUBSTR_REGEXPR( '([;])([^;]*)(?=;)'
    IN   CONCAT(CONCAT(';',ST.VALUE),';')
         OCCURRENCE NT.Element_Number
        GROUP 2
        ) splitted      -- string piece
    from 
    "_SYS_BIC"."Financial_Planning_and_Analysis/ZZTPARPAR_SOURCE" as ST, -- source  table
    SERIES_GENERATE_INTEGER(1, 0, 10 ) as NT -- numbers table
        ) tbl
    where splitted is not null
    order by PARAM, Element_Number;
    End     
    

    Before and After

提交回复
热议问题