Skip to Content

Transform table using sql statements in SAP HANA

May 28, 2017 at 10:58 AM


avatar image
Former Member


I posted this question yesterday and it has been deleted with a comment, failed to search, there were many blogs which i have gone through which were done using hana modeler. whereas i need to write the same in SQL.

I am very new to hana environment. I was introduced to write sql quaries to retrieve data from tables.

I have a table in SAP HANA environment with an Id and the items that were ordered by the IDs.

Table is as follows:

|CustomerID| Items |
|Customer1| Item 1|
|Customer1| Item 2|
|Customer1| Item 3|
|Customer1| Item 4|
|Customer1| Item 5|
|Customer2| Item 1|
|Customer2| Item 3|
|Customer2| Item 6|

I would like to transform the table as follows:

|CustomerID| Item 1| Item 2| Item 3| Item 4| Item 5| Item 6|

I would like to write a function or procedure that does the task by iterating over the distinct items, as the length of the distinct items column varies according to requirement.

Any help is very much appreciated!

Thank you!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers