Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

Dynamically pivoting a table in SAP HANA

$
0
0

In this thread

http://scn.sap.com/thread/3527126

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: http://buysql.com/mysql/14-how-to-automate-pivot-tables.html

 

SET @sql = NULL;

SELECT

  GROUP_CONCAT(DISTINCT

    CONCAT(

      'MAX(IF(property_name = ''',

      property_name,

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

      property_name

    )

  ) 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? 


Viewing all articles
Browse latest Browse all 5653

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>