Fetch Next Record Data

How can we fetch next record data for a particular field in ab initio?
i/p
id sal
101 500
102 800
103 900
105 200
o/p
id sal Next_sal
101 500 800
102 800 900
103 900 200
105 200 NULL

Showing Answers 1 - 1 of 1 Answers

Nishad P

  • Feb 25th, 2024
 

use below flow,
i/p -> reformat -> rollup -> normalize -> o/p
reformat:
add one more column with constant value
out.id :: 1;
out.* ::in.*;
rollup :
group the data based on column id created in reformat also make both main columns to vector in DML and add transform in rollup as
out.custno ::accumulation(in.col1);
out.amount :: accumulation(in.col2);
normalize :
let decimal("|") ind = 0;
out::length(in)=
begin
out :: 4;
end;
/*Do computation*/
out::normalize(in,index)=
begin
ind = index+1;
out.col1 ::in.col1[index];
out.col2_1 :: in.col2[index];
out.col2_2 :: if(ind+1 > 4) NULL else in.col2[index+1];
end;
with dml :
record
decimal("|") col1;
decimal("|") col2_1;
decimal("
") col2_2 = NULL;
end;
output :
col1 col2_1 col2_2
101 500 800
102 800 900
103 900 200
105 200 Null

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions