Hi
I have
--Table Structure & Result
select Field1='P001',Field2='A',Field3='A1',USD_Company__A=1000,USD_Company__B=null,USD_Company__C=766551,AUD_Company__A=null union all
select Field1='P001',Field2='B',Field3='A2',USD_Company__A=null,USD_Company__B=null,USD_Company__C=1111,AUD_Company__A=2222 union all
select Field1='P001',Field2='C',Field3='A3',USD_Company__A=1000,USD_Company__B=4000,USD_Company__C=1000,AUD_Company__A=9000
--How to Transform above Table Structure & Data to be as below resultset ???
select Field1='P001',Field2='A',Field3='A1',Currency='USD',Company='Company A',Amount=1000 union all
select Field1='P001',Field2='A',Field3='A1',Currency='USD',Company='Company B',Amount=null union all
select Field1='P001',Field2='A',Field3='A1',Currency='USD',Company='Company C',Amount=766551 union all
select Field1='P001',Field2='A',Field3='A1',Currency='AUD',Company='Company A',Amount=null union all
select Field1='P001',Field2='B',Field3='A2',Currency='USD',Company='Company A',Amount=null union all
select Field1='P001',Field2='B',Field3='A2',Currency='USD',Company='Company B',Amount=null union all
select Field1='P001',Field2='B',Field3='A2',Currency='USD',Company='Company C',Amount=1111 union all
select Field1='P001',Field2='B',Field3='A2',Currency='AUD',Company='Company A',Amount=2222 union all
select Field1='P001',Field2='c',Field3='A3',Currency='USD',Company='Company A',Amount=1000 union all
select Field1='P001',Field2='c',Field3='A3',Currency='USD',Company='Company B',Amount=4000 union all
select Field1='P001',Field2='c',Field3='A3',Currency='USD',Company='Company C',Amount=1000 union all
select Field1='P001',Field2='c',Field3='A3',Currency='AUD',Company='Company A',Amount=9000
The <><><<CompanyName (SPACE represent with __)>> is a dynamic list not static columns name.
Please advise.
Thanks
Regards,
Micheale