sql - Transpose Columns to Rows - Teradata -
i have 2 tables following data
tablea types columna columnb columnc dart 8.00 9.00 10.00 tableb types descp acnt dart columna 14000 dart columnb 15000 dart columnc 16000
my expected output
types amt acnt dart 8.00 14000 dart 9.00 15000 dart 10.00 16000
i have written following code output
select x.types, case when descp='columna' columna when descp='columnb' columnb when descp='columnc' columnc else null end amt, b.acnt tablea x join tableb y on x.types=y.types
these sample data , there around 10 types , more 10 columns. there other option apart writing case statements including columns achieve this? thanks
use teradata td_unpivot it's purpose need.
Comments
Post a Comment