Page 1 of 1

Help for logic

Posted: Thu Aug 09, 2007 9:16 am
by reddy12
Hi

I need some help about my logic.

My input data is like below

ID Type
1001 20
1001 20
1001 20
1003 20
1003 23
1003 20
1003 23
1010 20
1010 23
1010 20
1010 23
1010 24
1010 24
1010 24
1010 24
1013 24
1013 24
So
1.if same ID has Type only 20 then i need output of that all ID's of that 20
2.if same ID has type 20&23 then no need that id's of 20 & 23
3.If same Id has Type 20,23&24 then we need Only ID's of that all 24.

So my out put is
ID Type
1001 20
1001 20
1001 20
1010 24
1010 24
1010 24
1010 24
1013 24
1013 24


finally we need all 24 type id's and if the id has only 20 then we need that ID.no need if same id has type 20 and 23

Re: Help for logic

Posted: Thu Aug 09, 2007 9:18 am
by reddy12
The above data is from Sequential files.I want out put also seq.file
Please give me Idea

reddy12 wrote:Hi

I need some help about my logic.

My input data is like below

ID Type
1001 20
1001 20
1001 20
1003 20
1003 23
1003 20
1003 23
1010 20
1010 23
1010 20
1010 23
1010 24
1010 24
1010 24
1010 24
1013 24
1013 24
So
1.if same ID has Type only 20 then i need output of that all ID's of that 20
2.if same ID has type 20&23 then no need that id's of 20 & 23
3.If same Id has Type 20,23&24 then we need Only ID's of that all 24.

So my out put is
ID Type
1001 20
1001 20
1001 20
1010 24
1010 24
1010 24
1010 24
1013 24
1013 24


finally we need all 24 type id's and if the id has only 20 then we need that ID.no need if same id has type 20 and 23

Posted: Thu Aug 09, 2007 9:20 am
by swades
How many possible value for type?It only just 3 or more? :?

Posted: Thu Aug 09, 2007 10:48 am
by reddy12
Its' just 3

swades wrote:How many possible value for type?It only just 3 or more? :?

Posted: Thu Aug 09, 2007 11:16 am
by g_rkrish
reddy12 wrote:Its' just 3

swades wrote:How many possible value for type?It only just 3 or more? :?
Do a IF then Else on you constraint to filter your records....

Posted: Thu Aug 09, 2007 11:35 pm
by Maveric
Do a vertical pivot. Get all the values for a particular ID in one row. Like
1001 20
1001 23
1001 24
And the out put will be like 1001 20 23 24, in one record.
Then it is a straight forward If Then Else logic. Do a search on Vertical Pivot to know how to do it.

Re: Help for logic

Posted: Fri Aug 10, 2007 12:06 am
by hemachandra.m
I have a solution but it will in terms of server job.

Create a dummy hash file somewhere.

In this job have the hash file as lookup as well as update stage. The hash file will have id as key and a column like flag.


Logic : Update the value of flag with "Y" if it 20 Or 24 and "N" if it is "23".

Before updating check if the hash file has a value "N" for that id key. If yes then take "N" Else Use the above logic.

So the hash file will have like below after this job

1001 Y
1003 N
1010 Y
1013 Y

So in the next job have the input to lookup this hash file and pass the records for which the key has "Y".

Re: Help for logic

Posted: Fri Aug 10, 2007 12:12 am
by hemachandra.m
I am sorry, the logic has to be changed a bit.i will try to give in some time.

Re: Help for logic

Posted: Fri Aug 10, 2007 12:16 am
by hemachandra.m
Will the type come in order like 20 followed by 23 followed by 24 or for the same id 20,23& 24 can come in any order.

Re: Help for logic

Posted: Fri Aug 10, 2007 12:59 am
by G SHIVARANJANI
Pls check
the topic "Logic Help" or search for "Logic Help"

viewtopic.php?t=112175
reddy12 wrote:Hi

I need some help about my logic.

My input data is like below

ID Type
1001 20
1001 20
1001 20
1003 20
1003 23
1003 20
1003 23
1010 20
1010 23
1010 20
1010 23
1010 24
1010 24
1010 24
1010 24
1013 24
1013 24
So
1.if same ID has Type only 20 then i need output of that all ID's of that 20
2.if same ID has type 20&23 then no need that id's of 20 & 23
3.If same Id has Type 20,23&24 then we need Only ID's of that all 24.

So my out put is
ID Type
1001 20
1001 20
1001 20
1010 24
1010 24
1010 24
1010 24
1013 24
1013 24


finally we need all 24 type id's and if the id has only 20 then we need that ID.no need if same id has type 20 and 23