cancel
Showing results for 
Search instead for 
Did you mean: 

HANA SQL for Pivot

menona
Explorer
0 Kudos

Hi All

Have a scenario where I need to Pivot vendor amounts on Vendor amounts Type . There are only 2 amount types

I have attached table and required pivot results

Please let me know the SQL for this pivot

Regards

Accepted Solutions (0)

Answers (1)

Answers (1)

anindya_bose
Active Contributor
0 Kudos

Try this.

( SELECT VENDOR , SUM ( AMOUNT) AS T1 , 0 AS T2 FROM TABLE

WHERE AMOUNT_TYPE T1

GROUP BY VENDOR )

UNION ALL

( SELECT VENDOR, 0 AS T1 , SUM( AMOUNT) AS T2  FROM TABLE

WHERE AMOUNT_TYPE T2

GROUP BY VENDOR )

It would be easier to try individual statement first before joining them by Union ALL .

Cheers

Anindya