Home > database >  Dynamic multiple rows merged into a DB2 data
Dynamic multiple rows merged into a DB2 data

Time:09-23


Want to merge the duplicate data, so that repeated data can have multiple, need to be merged, red box of the data has a comma to merge, the great spirit guide,
Urgent urgent!!!!!!!!!!!!!!

CodePudding user response:

The select f1, f2, f3, f4 and f5, replace (replace (xml2clob (xmlagg (xmlelement (NAME A, f6 | | ', '))), '& lt; A> ', ' '), '& lt;/A> ', ' ') FROM the TB GROUP BY f1, f2, f3, f4 and f5

Including f1, f2, f3, f4 and f5 to grouping columns, then f6 is to merge the column, there's no need to change the NAME A, only XML tags,

CodePudding user response:

Do it, as if a function list_agg have this effect

CodePudding user response:

The select f_id listagg (type, ', ') from tb_name group by f_id

CodePudding user response:

Use listagg functions to merge
  •  Tags:  
  • DB2
  • Related