DB2: Function to merge 3 column output

This works in z/OS versions at least:

select c1 concat ' ' concat c2 concat ' ' concat c3

Get to know the DB2 documentation


try this.

select concat(concat (c1,c2),c3) from table1

I came across the same problem recently, I used the || (double pipes) in order to concat to columns.

I also had to write a wrapper to in my query to overcame the issue.

Below is a snippet of what my queries looked like in the end.

select a1 || a2 as a2, a3 || a4 as a4 --wrapper 2
from (
select '"service":"' as a1,a2, '","total":' as a3, a4 --wrapper 1
from (
select distinct(a2),count(*) as a4 
from abc.table
group by a2 
order by a2)
);

Below is what the ouput was from the query:

"service":"ABC" , "total":123

Tags:

Sql

Db2