DB2: function for joining three columns

I have below entries in table 1

c1 c2 c3 ---------- ABC 

How to merge c1 c2 and c3 so that the output would like

ABC with space between output I used the concat function but did not accept 3 arguments as

 select concat (c1,c2,c3) from table1 

I cannot run select * from table1 since I want output in one column

+6
source share
4 answers

This works in z / OS versions at least:

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

Check out the DB2 documentation

+9
source

try it.

 select concat(concat (c1,c2),c3) from table1 
+3
source

Recently, I ran into the same problem, I used || (double pipes) to run columns.

I also had to write a wrapper in my request to overcome this problem.

Below is a snippet of what my queries looked like at 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) ); 

The following is the information from the request:

 "service":"ABC" , "total":123 
+2
source

I am having a problem converting from SQL to DB2. This page helped, but I changed a bit:

 SELECT RTRIM(C1) || '' || C2 as CFULL FROM TABLE 
0
source

All Articles