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