If I have a data like this:
GROUP | SEQUENCE | COMMAND
------------------------------
ONE | 3 | <message2>MESSAGE</message2>
ONE | 1 | <?xml version="1.0" encoding="UTF-8"?>
ONE | 2 | <message1>MESSAGE</message1>
TWO | 2 | <message2>MESSAGE</message2>
TWO | 1 | <?xml version="1.0" encoding="UTF-8"?>
........
TWO | 10 | <message9>MESSAGE</message9>
How can I concatenate the command to be like this:
GROUP | COMMAND
-----------------
ONE | <?xml version="1.0" encoding="UTF-8"?>,<message1>MESSAGE</message1>,<message2>MESSAGE</message2>
TWO | <?xml version="1.0" encoding="UTF-8"?>,<message1>MESSAGE</message1>, .. ,<message9>MESSAGE</message9>
I used this query below but the command column is not in order according to their sequence number:
SELECT GROUP, WM_CONCAT(COMMAND) AS COMMAND
FROM (SELECT GROUP, SEQUENCE, COMMAND FROM TBL ORDER BY SEQUENCE)
GROUP BY GROUP
//AND THIS
SELECT GROUP, WM_CONCAT(DISTINCT COMMAND) AS COMMAND
FROM (SELECT GROUP, SEQUENCE, COMMAND FROM TBL ORDER BY SEQUENCE)
GROUP BY GROUP
Any advice and suggestions will be greatly appreciated. ^_^