Quantcast
Channel: Pentaho Community Forums
Viewing all articles
Browse latest Browse all 16689

Dynamic row to column conversion

$
0
0
Hi,

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

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):-
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

Viewing all articles
Browse latest Browse all 16689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>