Sometimes, it's really usefull to transform rows into a column.
It's very easy in PostgreSQL with
string_agg function :
select
cus.customer_key
, cus.first_name
, cus.last_name
, select string_agg(card.card_key, ',') from customer_cards card where card.customer_key = cus.customer_key
from
customers cus;
For more informations about functions aggregate in PostgreSQL, consult the
official documentation
.
Another tip, if you want to know the version of PostgreSQL :