I am using DB2 v9 and trying to get country values in comma seperated format using below query
SELECT distinct LISTAGG(COUNTRIES, ',') WITHIN GROUP(ORDER BY EMPLOYEE)
FROM LOCATION ;
Output Achieved
MEXICO,UNITED STATES,INDIA,JAPAN,UNITED KINGDOM,MEXICO,UNITED STATES
The table "LOCATION" has multiple columns apart from Employee and Country and hence i cant group on countries to remove duplicate countries values .
Is there a way to remove dups to get only countries once using above query with modification .
Expected Output ( Should exclude MEXICO,UNITED STATES as these two countries are duplicated)
MEXICO,UNITED STATES,INDIA,JAPAN,UNITED KINGDOM
Any help appreciated.