issue with string_agg with distinct in postgres
array_to_string(array_agg(distinct column_name::text), '; ')
Will get the job done
select string_agg(distinct 'pre' || user.col, 'post')
As the above will deny the use of an index in the distinct
aggregation take the 'pre'
out
select 'pre' || string_agg(distinct user.col, 'postpre')
The concat function can help you.
select string_agg(distinct concat('pre',user.col, 'post'), '')