cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Transpose rows to columns

former_member182343
Active Contributor
0 Kudos

Hi All,

I need to convert rows to columns as per below requirement.

Can anyone help with SQL in HANA .

Thanks in advance.

former_member358098
Participant
0 Kudos

Hello.

Something like this ?

select distinct order,
item,
sequence,
(select costcenter from <table> where order = <alias>.order and item = <alias>.item and sequence = <alias>.sequence and position = 'A1') CostCenterPosA1,
(select costcenter from <table> where order = <alias>.order and item = <alias>.item and sequence = <alias>.sequence and position = 'A2')CostCenterPosA2,
(select costcenter from <table> where order = <alias>.order and item = <alias>.item and sequence = <alias>.sequence and position = 'A3')CostCenterPosA3
from <table> <alias><br>

Accepted Solutions (0)

Answers (1)

Answers (1)

KonradZaleski
Active Contributor
0 Kudos

Hi Vijay,

Please check the existing thread on sap community. There is very similair scenario described so you could adjust the logic to your requirements.