Hi,
I need to convert data from rows to columns dynamically. Let me explain it with example.
Say, source data is:-
I need excel output where company_id will become header and amt will become corresponding value under the header. Here is the expected output (excel):-
Number of rows in source data is not fixed. In sample data, it is having 8 rows and hence, excel output is having 8 columns. However it should be dynamic. If source data is having 20 rows, then I should be having 20 columns in excel output.
Request you all to take a look. Any help will be much appreciated.
Regards,
Ritesh
I need to convert data from rows to columns dynamically. Let me explain it with example.
Say, source data is:-
Code:
select 'ABC-123' as company_id, 4343 amt from dual union all
select 'PQR-111' as company_id, 1111 amt from dual union all
select 'XYZ-222' as company_id, 2345 amt from dual union all
select 'DDD-333' as company_id, 9999 amt from dual union all
select 'IJK-444' as company_id, 1122 amt from dual union all
select 'KLM-555' as company_id, 3344 amt from dual union all
select 'BRT-666' as company_id, 5555 amt from dual union all
select 'IND-777' as company_id, 6666 amt from dual
ABC-123 | PQR-111 | XYZ-222 | DDD-333 | IJK-444 | KLM-555 | BRT-666 | IND-777 |
4343 | 1111 | 2345 | 9999 | 1122 | 3344 | 5555 | 6666 |
Number of rows in source data is not fixed. In sample data, it is having 8 rows and hence, excel output is having 8 columns. However it should be dynamic. If source data is having 20 rows, then I should be having 20 columns in excel output.
Request you all to take a look. Any help will be much appreciated.
Regards,
Ritesh