I am trying to combine multiple data points into one cell using coalesce and ifnull with carriage returns between the combined data points. If I remove the second coalesce statement it works, but so far no luck combining more than two sets of data. Any thoughts would be greatly appreciated. I am using SQL in DB2.
Basically I want the following results from the SQL statement:
Bob, LCE
Fred, LBD
Julie, LNJ
select
nullif(b.column03,'') || ', ' || nullif(b.column04,'')
|| coalesce(chr(10) || nullif(b.column05,'') || ', ' ||
nullif(b.column06,''),'')
|| coalesce(chr(10) || nullif(b.column07,'') || ', ' ||
nullif(b.column08,''),'')
as "Presenter/Agency"
from [ETL redacted] b
order by 1,2,3,4