Redshift. Convert comma delimited values into rows

后端 未结 8 1188
北恋
北恋 2020-12-01 06:25

I am wondering how to convert comma-delimited values into rows in Redshift. I am afraid that my own solution isn\'t optimal. Please advise. I have table with one of the colu

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 07:11

    You can get the expected result with the following query. I'm using "UNION ALL" to convert a column to row.

    select user_id, user_name, split_part(user_action,',',1) as parsed_action from cmd_logs
    union all
    select user_id, user_name, split_part(user_action,',',2) as parsed_action from cmd_logs
    union all
    select user_id, user_name, split_part(user_action,',',3) as parsed_action from cmd_logs
    

提交回复
热议问题