3

How do i remove the brackets {} from an Array_AGG query output?

ARRAY_AGG(DISTINCT(SGL.short_name))

from this {01,02} to this 01|02|

thanks!

1
  • 1
    distinct is NOT a function. Commented Aug 21, 2015 at 5:44

2 Answers 2

12

Use string_agg instead.

string_agg(DISTINCT SGL.short_name, '|')
Sign up to request clarification or add additional context in comments.

Comments

7

Use array_to_string():

ARRAY_TO_STRING(ARRAY_AGG(DISTINCT(SGL.short_name)), '|')

2 Comments

Is it possible to change the order of the output from 01|02|03|04|05|KG|PK to PK|KG|01|02|03|04|05 ?
@user3263892 . . . Yes, you would add an order by clause.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.