0

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

jarlh
  • 42,561
  • 8
  • 45
  • 63
  • Luckily, [there is documentation](https://www.ibm.com/docs/el/db2-for-zos/12?topic=expressions-concatenation-strings) – HoneyBadger May 06 '22 at 13:55
  • Does this answer your question? [SQL concatenate rows into one field (DB2)](https://stackoverflow.com/questions/44805101/sql-concatenate-rows-into-one-field-db2) – A.Steer May 06 '22 at 13:58

1 Answers1

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;
Ankit Bajpai
  • 13,128
  • 4
  • 25
  • 40