how to split a column that is created with array_agg

Viewed 2016

I'm trying to split up an arrayed column that was created using an array_agg. the following is severely cut down, original query is something like 210 lines

select 
 distinct on (visitor.id)
 id,
 array_agg(distinct item.code::text)

from
 8xfullouter joins

where
exists(
select
distinct on(visitor.id)
item.code::text
from
3 full outer join that all appear in the first query

group by
visit.id, 
item.code

order by 
visit.id
)

I need to break the array_agg(distinct item.code::text) into multiple columns. I've tried split_part(array_agg(distinct item.code::text), ',', 1) but received the following

> [Err] ERROR:  function split_part(character varying[], unknown,
> integer) does not exist LINE 159: split_part (array_agg(distinct
> "public".procedure_group_cpt_...

thanks!!!

1 Answers
Related