Hello DB2 Expert,
Here a little big problem
Table to contain source data
Expected Result set
There are not fixed values about the number of same CODFORN number.
This topic has been locked.
4 replies Latest Post - 2013-03-28T13:16:11Z by SystemAdmin
Pinned topic DB2 SQL a Little Big Problem
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-03-28T13:16:11Z at 2013-03-28T13:16:11Z by SystemAdmin
Re: DB2 SQL a Little Big Problem2013-03-27T23:35:02Z in response to SystemAdminWhat you are describing is possibly a PIVOT table. (https://www.ibm.com/developerworks/mydeveloperworks/blogs/SQLTips4DB2LUW/entry/pivoting_tables56?lang=en)
Are you looking at getting a result set with multiple columns representing CODCOMP, or a single VARCHAR concatenated CODCOMP field?
Re: DB2 SQL a Little Big Problem2013-03-28T13:16:11Z in response to SystemAdminHere the solution
SUBSTR(XMLCAST(XMLGROUP(';' || codcomp AS a
ORDER BY codcomp)
AS VARCHAR(60)), 2) AS codcomp
GROUP BY codforn;
thanks a lot for your support