SELECT TABLE_NAME, MAX(COMMENTS) AS TAB_COMMENTS, WM_CONCAT(COLUMN_NAME)
FROM (
SELECT A.TABLE_NAME, C.COMMENTS, A.COLUMN_NAME||'(‘||TRIM(B.COMMENTS)||’)’ AS COLUMN_NAME
FROM ALL_IND_COLUMNS A, ALL_COL_COMMENTS B, ALL_TAB_COMMENTS C
WHERE A.TABLE_NAME = B.TABLE_NAME
AND A.COLUMN_NAME = B.COLUMN_NAME
AND A.TABLE_NAME = C.TABLE_NAME
AND A.TABLE_NAME LIKE ‘TB_%’
)
GROUP BY TABLE_NAME