I have below records in table1
c1 c2 c3
----------
A B C
How to merge c1 c2 and c3 so the output would like
A B C with space in between the output I used concat function but its not taking 3 arguments like
select concat (c1,c2,c3) from table1
I cant run select * from table1
as I want output in one column
To concatenate more than 2 fields with SQL, you can use CONCAT() or CONCAT_WS() function.
In SQL SELECT statements, you can concatenate columns by using a special operator “||” or using CONCAT function.
You can concatenate strings by using the CONCAT operator or the CONCAT built-in function. When the operands of two strings are concatenated, the result of the expression is a string. The operands of concatenation must be compatible strings.
MERGE has more flexible OUTPUT . OUTPUT can refer to the merge source which is handy if you want the client to be able to match what it sent to what was actually inserted (e.g. IDENTITY values).
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With