Help for logic

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
reddy12
Participant
Posts: 99
Joined: Tue Aug 08, 2006 9:34 pm

Help for logic

Post 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
reddy12
Participant
Posts: 99
Joined: Tue Aug 08, 2006 9:34 pm

Re: Help for logic

Post 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
swades
Premium Member
Premium Member
Posts: 323
Joined: Mon Dec 04, 2006 11:52 pm

Post by swades »

How many possible value for type?It only just 3 or more? :?
reddy12
Participant
Posts: 99
Joined: Tue Aug 08, 2006 9:34 pm

Post by reddy12 »

Its' just 3

swades wrote:How many possible value for type?It only just 3 or more? :?
g_rkrish
Participant
Posts: 264
Joined: Wed Feb 08, 2006 12:06 am

Post 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....
RK
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post 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.
It is our choices that show what we truly are, far more than our abilities - J.K.Rowling
hemachandra.m
Participant
Posts: 27
Joined: Wed Jan 03, 2007 1:29 am

Re: Help for logic

Post 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".
Hemachandra
hemachandra.m
Participant
Posts: 27
Joined: Wed Jan 03, 2007 1:29 am

Re: Help for logic

Post by hemachandra.m »

I am sorry, the logic has to be changed a bit.i will try to give in some time.
Hemachandra
hemachandra.m
Participant
Posts: 27
Joined: Wed Jan 03, 2007 1:29 am

Re: Help for logic

Post 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.
Hemachandra
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Re: Help for logic

Post 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
Shivaranjani
Post Reply