Hi ,
I always need to show the amount in 4 columns only .
For ex :
If there are 6 rows in table , 1st row should have 4 columns and 2nd row should have 2 columns
If there are 9 rows in table , 1st row should have 4 columns and 2nd row should have 4 columns and 3rd row should have 1 column.
with t as
( select 100 s_id , 1276 amount from dual union all
select 100 s_id , 5678 amount from dual union all
select 100 s_id , 2324 amount from dual union all
select 100 s_id , 4532 amount from dual union all
select 100 s_id , 1209 amount from dual union all
select 100 s_id , 8901 amount from dual )
select s_id ,amount from t
expected output
--In Row 1
amount_1 amount_2 amount_3 amount_4
1276 5678 2324 4532
--In Row 2
1209 8901 0 0