issue with string_agg with distinct in postgres

postgresql

Solution

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')

Problem

I am getting error for below query. Basically to use `||` & `distinct` together. ``` select string_agg( 'pre' || distinct user.col, 'post') ``` It works fine like this ``` select string_agg( 'pre' || user.col, 'post') ``` & this ``` select string_agg(distinct user.col, 'post') ```

Original source