Page 1 of 1

Logic for finding sequence Gap

Posted: Tue Jun 27, 2006 6:03 am
by opdas
Hi,
I have this situation where I need to find the gaps in the sequence and write all the gap in a file.


Source is like

Code: Select all

Col1     Col2
A            1
A            3
A            4
B            2
B            5
B            7
The target would be:

Code: Select all

Col1      Col2
A            2
B            3
B            4
B            6
I have to take into account the Max and Min value in Col2 and find sequence gaps for each unique entry for Col1.

Any idea is appreciated.

Regards
Om

Posted: Tue Jun 27, 2006 6:31 am
by balajisr
Sort by Col1, Col2 use stage variables to find the gap in the sequence and write to the target.

Posted: Tue Jun 27, 2006 6:34 am
by DSguru2B
Yes, a group change dance is required that can be accomplished via stage variables. THis has been discussed here a lot. Make the search engine your best friend :wink:

Posted: Tue Jun 27, 2006 8:25 am
by kumar_s
How many records will be there in the gap?
If the number of record in the gap is less, say 1 or 2 or 3 it ok, else you need to have that many stage variable to hold the values to compare and give as output.
For that case, you can build you own custome stages or routien to have the looping funtion in it.

Posted: Wed Jun 28, 2006 1:21 am
by opdas
How can I compare current record with previous record in stage variable? Can stage variable store previous record value or it is reset for every new record?

I tried searching but couldnt get to the right topic ...If any one has the link or keyword to search would be of great help.

Posted: Wed Jun 28, 2006 3:21 am
by dwblore
opdas wrote:How can I compare current record with previous record in stage variable? Can stage variable store previous record value or it is reset for every new record?

I tried searching but couldnt get to the right topic ...If any one has the link or keyword to search would be of great help.
Life of the stage variable is the stage itself ie it lives until the entire recordset is processed.

Have Two Stg Varaibles
Old
New

Where Old=New
and New is populated with the desired column

LTRA_HLP

Posted: Wed Jun 28, 2006 3:26 am
by mani_dwbi
[quote="opdas"]How can I compare current record with previous record in stage variable? Can stage variable store previous record value or it is reset for every new record?

I tried searching but couldnt get to the right topic ...If any one has the link or keyword to search would be of great help.[/quote]

Hello OPD,
The best link what i think tht, please look into Duplicate CDR check JOb(for intec).

Posted: Wed Jun 28, 2006 3:56 am
by kumar_s
As mentioned have two stage variable.

Initial declaration
Old = ''
New = ''

Stage variable derivation
Old = New
New = Input Column.


If Old = New Then {logic for duplicate} else {logic for new}

Posted: Wed Jun 28, 2006 5:30 am
by opdas
Kumar:
Thanks a lot , its working now, I should have got this before :shock:

Mani:
Thanks for the reply...... I'll definetly search your Intec Jobs :wink: