In Netezza, GROUP_CONCAT function does not support ORDER BY, it uses its own internal order by, which is order by the column you use as parameter.
SELECT 'GROUP BY '||TOOLKIT.SQLEXT.GROUP_CONCAT(PRIMARY_KEY, ', ') AS GROUP_BY
FROM (
SELECT 1 AS SEQ, 'DATA_DATE' AS PRIMARY_KEY
UNION ALL
SELECT 2 AS SEQ, 'ACCT_ID' AS PRIMARY_KEY
) S;
This will return:
GROUP_BY GROUP BY ACCT_ID, DATA_DATE
But how to get result order by SEQ instead of PRIMARY_KEY to get result like this:
GROUP_BY GROUP BY DATA_DATE, ACCT_ID