Over vs Runs -- same sequence number for each group

I am having input column as runs with values
3
2
4
6
0
1
0
3
2
6
0
0
4
1
1
2
3
In output I want over number on Over column and corresponding runs on Runs column
Expected o/p is:-
Over Runs
1 2
1 4
1 6
1 3
1 0
1 1
2 0
2 3
2 2
2 6
2 0
2 0
3 4
3 1
3 1
3 2
3 3

Showing Answers 1 - 17 of 17 Answers

Amaan Ansari

  • Feb 5th, 2021
 

There are multiple ways to do it.
Simplest way is to use a reformat

Use a reformat

In the input
Record
Decimal (‘|’) Runs;
End

In the output dml
Runs
Over


In the transform 

Out.run :: in.run
Out.over :: decimal_rounddown((next_in_sequence/6) + 1,0)

  Was this answer useful?  Yes

Kiran

  • Mar 1st, 2021
 

Hi Amaan, This is the simplest and easy solution with one fault. For the first over, it shows only 5 balls as at 6th place, from roundown we are getting 6/6 as 1 and adding 1 to that makes it 2, so second over starts from it. To resolve this, need to subtract 1 from next_in_sequence.

  Was this answer useful?  Yes

shivank b

  • Apr 4th, 2021
 

We can make slight change in aamans solution.
Out.run :: in.run
Out.over :1: if (next_in_sequence()%6 != 0) decimal_rounddown((next_in_sequence/6) + 1,0)
Out.over :: (next_in_sequence/6)

  Was this answer useful?  Yes

Vishal

  • Oct 20th, 2021
 

why did you use decimal_round_down() function here? I see code can work fine without it also.

  Was this answer useful?  Yes

Anurag

  • Nov 22nd, 2022
 

let decimal(2) over=0;
out::reformat(in)=
begin
if (((next_in_sequence()-1)%6)==0)over=over+1;
out.over :: over;
out.run::in.rec;
end;

  Was this answer useful?  Yes

Ahmad Ali Quraishi

  • Jan 6th, 2024
 

Reformat:
let int over=0;
out :: reformat(in)
begin
if(next_in_sequence()%6==1)over=over+1;
out.over :: over;
our.run :: in.run;
end;

  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