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
此代码将某些值作为行排除。甚至可以将这些作为具有自定义列名称的列排除吗?
答案 0 :(得分:1)
您可以通过它的索引访问数组的每个元素,例如:
select a[1] as first, a[2] as second, a[3] as third
from string_to_array('batman,v,superman', ',') a