selecting one record out of 2 records
Moderators: chulett, rschirm, roy
selecting one record out of 2 records
I have data as mentioned below.source is sequential file
source,destination,distance
chennai,hyderabad,500
hyderabad,chennai,500
chennai,bangalore,600
bangalore,chennai,600
chennai,bangalore,600
I have to select 1 record out of 2 records.ay record is fine.
chennai,hyderabad,500
hyderabad,chennai,500
I need algorithim how to proceed and then i will think about logic
source,destination,distance
chennai,hyderabad,500
hyderabad,chennai,500
chennai,bangalore,600
bangalore,chennai,600
chennai,bangalore,600
I have to select 1 record out of 2 records.ay record is fine.
chennai,hyderabad,500
hyderabad,chennai,500
I need algorithim how to proceed and then i will think about logic
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Simply repeating your post doesn't help any of us understand it better. Your example doesn't seem to match up to your words. "1 out of 2 records" means what exactly - every other record? Every even? Every odd? Something else entirely? All your example shows are the first two records being 'selected'.
So, until you can properly explain what it is you need, no-one will be able to help you without guessing. Never mind the fact that once you do, the answer may become clear to you as well!
So, until you can properly explain what it is you need, no-one will be able to help you without guessing. Never mind the fact that once you do, the answer may become clear to you as well!
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
I have concatenated as mentioned below
Start,End,Start_End,End_Start,Distance
Bangalore,Mumbai,BangaloreMumbai,MumbaiBangalore,1500
Hyderabad,Delhi,HyderabadDelhi,DelhiHyderabad,2000
Delhi,Hyderabad,DelhiHyderabad,HyderabadDelhi,2000
Mumbai,Bangalore,MumbaiBangalore,BangaloreMumbai,1500
How to use above Start_End,End_Start columns for comparisions?
Start,End,Start_End,End_Start,Distance
Bangalore,Mumbai,BangaloreMumbai,MumbaiBangalore,1500
Hyderabad,Delhi,HyderabadDelhi,DelhiHyderabad,2000
Delhi,Hyderabad,DelhiHyderabad,HyderabadDelhi,2000
Mumbai,Bangalore,MumbaiBangalore,BangaloreMumbai,1500
How to use above Start_End,End_Start columns for comparisions?
-
- Participant
- Posts: 527
- Joined: Thu Apr 19, 2007 1:25 am
- Location: Melbourne
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Are you the same user as vamsi.4a6, who has over 330 posts?
Anyway, and irrespective of that, think about the present problem this way: what is the purpose of constructing Start:End and End:Start columns?
The answer to that is that, if they are the same, then the records belong in the same group.
From that you can use whatever technique you like, for example the LastRowInGroup() function or "remembering" stage variables, to identify a single record from that group.
And I guess you'll need to get yourself a premium membership.
Anyway, and irrespective of that, think about the present problem this way: what is the purpose of constructing Start:End and End:Start columns?
The answer to that is that, if they are the same, then the records belong in the same group.
From that you can use whatever technique you like, for example the LastRowInGroup() function or "remembering" stage variables, to identify a single record from that group.
And I guess you'll need to get yourself a premium membership.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 527
- Joined: Thu Apr 19, 2007 1:25 am
- Location: Melbourne
Come on, man. You've got a blog.vamsi_4a6 wrote:I stuckup with how to compare two records within a group ans selecting one record out of it.
Seriously, order the names alphabetically in a transformer and then remove duplicates.
eg:
Here There 666
There Here 666
Becomes
Here There 666
Here There 666
Now pick one.
I want my 2 minutes back.
Sheesh.
-
- Participant
- Posts: 36
- Joined: Thu Dec 03, 2009 9:11 pm
- Location: Malaysia
Hi,vamsi_4a6 wrote:Anybody help on how to proceed?
Step1: First sort the rows where you wanted to check with
Example : a b 100
b a 200
After you sort the above records it would be like the below:
a b 100
a b 200
Use the remove duplicate stage to get either the first record or the second records.(Keep those 2 column as key column)
I hope you understood !!!
Reply back if not.
Regards
Naveen
Naveen Kumar
Datastage Consultant
Datastage Consultant