Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Dynamically pivoting a table in SAP HANA

In this thread

OP asks for an option to pivot a table in HANA.

The solution works, but I am interested in a dynamic solution so that it automatically adapts to the structure of the table and the columns names do not need to be created manually everytime a table needs to be pivoted...something like this for MySQL:

SET @sql = NULL;




      'MAX(IF(property_name = ''',


      ''', value, NULL)) AS ',



  ) INTO @sql

FROM properties;

SET @sql = CONCAT('SELECT item_id, ', @sql, ' FROM properties GROUP BY item_id');

I have read the SCN forum and I do not want to do anything involving a calculation view or work with Data Services. Is there a way to do that? 

Former Member

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question