Issue with string_agg with non-postgres

I get an error for the request below. Mostly use || and distinct together.

 select string_agg( 'pre' || distinct user.col, 'post') 

It works great, like this one.

 select string_agg( 'pre' || user.col, 'post') 

& this is

 select string_agg(distinct user.col, 'post') 
+15
source share
2 answers
 select string_agg(distinct 'pre' || user.col, 'post') 

As stated above, using an index in distinct aggregation will result in 'pre' out

 select 'pre' || string_agg(distinct user.col, 'postpre') 
+23
source

The concat function can help you.

 select string_agg(distinct concat('pre',user.col, 'post'), '') 
0
source

Source: https://habr.com/ru/post/972331/


All Articles