Skip to Content
0
Former Member
Nov 14, 2014 at 12:44 PM

Concat Distinct rows into a single string

3305 Views

Hi,

In my table I have rows like this

Table Name : Test

Name

-----------------------

sam

khan

sun

sam

My query

Select string_agg(Name,',') from Test

Output

sam,khan,sun,sam

But it is giving Duplicate values like sam comes twice.

Please help me to Eliminate duplicates while using string_agg function