Convert rows into columns in Teradata

If the number of rows are not huge and it is known then the below query can be rendered to convert rows into columns in Teradata.
If we have 8 rows in the table, then
sel
        databasename
       ,tablename
       ,max(case when rnk = 1 then        ColumnName else '' end) ||
        max(case when rnk = 2 then ',' || ColumnName else '' end) ||
        max(case when rnk = 3 then ',' || ColumnName else '' end) ||
        max(case when rnk = 4 then ',' || ColumnName else '' end) ||
        max(case when rnk = 5 then ',' || ColumnName else '' end) ||
        max(case when rnk = 6 then ',' || ColumnName else '' end) ||
        max(case when rnk = 7 then ',' || ColumnName else '' end) ||
        max(case when rnk = 8 then ',' || ColumnName else '' end) ||
     /*** Indicating more than 8 rows ***/
        max(case when rnk > 8 then ',...' else '' end) as Columns
     from
       (
        sel
          databasename
         ,tablename
         ,trim(columnName) as ColumnName
         ,rank() over (partition by databasename, tablename
                       order by columnid) as rnk
        from
          dbc.columns
        where databasename = 'dbc'
       ) dt
     group by 1,2
     order by 1,2     ;