Sample Header Ad - 728x90

How to combine values ​in one column separated by commas

0 votes
1 answer
139 views
My code in postgre sql looks like this:
select
ouput.Serial ID as "Serial ID",
   case when ouput.parameters->>'10' = 'true' then 'hello' else '' end as "Hello",
   case when ouput.parameters->>'11' = 'true' then 'World' else '' end as "World"
from ouput
left join company_maintenance_entities abc on abc.id = ouput.maintenance_entity_id 
left join ouput_statuses on issue_statuses.id = ouput.status_id
where
    ouput.parameters->>'10' = 'true' or ouput.parameters->>'11' = 'true'
order by ouput.Serial ID
On output I get | Serial ID | Hello | World | | -------- | -------------- | -------------- | | 1| hello|World | | 2| | World | | 3| hello| | | 4| | World | | 5| hello| World | | 6| hello| World | How can I make query select sure that the Hello and World columns are joined in one column separated by commas and it turns out like this? | Serial ID | hello world | | -------- | -------------- | | 1| hello, world| | 2| world| | 3| hello| | 4| world| | 5| hello, world| | 6| hello, world|
Asked by H1Z1 (1 rep)
Apr 1, 2024, 03:54 PM
Last activity: Aug 9, 2025, 09:01 PM