我想取消嵌套多个值作为列

I want to unnest multiple values as columns

select
  case
    when subq.status = 1
        then unnest(
                        string_to_array('batman,v,superman', ',')
                )
    else null
  end as something
from (
    select 1 as status
) subq

此代码将某些值取消嵌套为行。甚至可以将它们取消嵌套为具有自定义列名的列吗?

您可以通过索引访问数组的每个元素,例如:

select a[1] as first, a[2] as second, a[3] as third
from string_to_array('batman,v,superman', ',') a