0

I want to select column "B" as a list when it's column "A" is the same. Say I have:

A                | B 
-----------------------------------
10000            | 5000         
10000            | 5000         
10001            | 9090        
10002            | 9090         
10000            | 9090 

As a result, I would like to have:

A                | B 
-----------------------------------
10000            | '5000,5000,9090'               
10001            | '9090'        
10002            | '9090'         

How should I go about this? Thanks all!

Kevin
  • 327
  • 6
  • 17

1 Answers1

0

You can try this

select A, array_to_string( array_agg("B"), ' , ') from tablename GROUP BY A order by A

for more reference visit this

Community
  • 1
  • 1
Mani Deep
  • 1,298
  • 2
  • 17
  • 33