'Concatenate the contents of two rows into one column (SQL DB2)

as it says in the title, I need to return two records but in the same column, for example (I clarify that the following code does not work, it is only to understand my case):

SELECT (NAMESS + "|" + LASTNAMESS), AGE
FROM PERSON

When doing the query, it would have to return something like Johnny|Depp in the first column and 45 in the second



Solution 1:[1]

There are 2 methods to concat the fields in DB2.

  1. CONCAT function -
SELECT CONCAT(NAMESS, LASTNAMESS), AGE
FROM PERSON;
  1. Concat Operator i.e. '||' -
SELECT NAMESS || LASTNAMESS, AGE
FROM PERSON;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ankit Bajpai