Find out first 2 records of each deptno?

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
jhansi
Participant
Posts: 33
Joined: Sat May 26, 2012 4:56 am

Find out first 2 records of each deptno?

Post by jhansi »

Find out first 2 records of each deptno?

source
delpno,name
10,vinodh
10,ashok
10,anil
10,raj
20,usha
20,puja
30,ravi
jhansi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:?

All of these generic questions with made up examples and zero explanation of what you've tried or what real world problem you are trying to solve look suspiciously like you are fishing for interview answers. That is something we do not condone here.

I'm this close to going back and either removing or locking this and other posts like it. Please convince me I shouldn't do that.

:!: In the meantime, I'm not going to allow answers to be posted until this is resolved.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

A lot of clutter on the forum will be reduced if posts such as these are deleted or moved to Trash :)
mobashshar
Participant
Posts: 91
Joined: Wed Apr 20, 2005 7:59 pm
Location: U.S.

Post by mobashshar »

I fully agree with you Criag.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Let me expand on this just so (hopefully) I'm being clear to whomever is reading this. And understand that I'm not trying to pick on you here, just attempting to do my job as a Moderator and explain How Things Work Here...

We are obviously here to help people, the number of years and posts that many people have on this site is a testiment to that. While the vast majority of questions raised are issues people are having with work they are attempting to perform, there is also the occassional curiousity post, which is fine as well. However, we do ask that you at least attempt to answer them on your own and then show us what you've tried and what went wrong when you tried it. When people come here with hat in hand and post something akin to "How do I do X" or "I need to get from A to B" with minimal (and typically made up) examples of source and target data and nothing else to back it up, it smacks of a couple of things:

1. Fishing for interview answers
2. Looking for someone to do their work for them

Number 1 is discouraged here. Number 2 is generally done for a fee. However, if you show us that you have at least attempted to solve the problem for yourself and the issues you've seen doing that, we're more than happy to help get you on the path to a solution. If you've searched the forums here for an answer but couldn't find anything relevant, say so. If you have no idea how to approach the problem, say so. If you are just experimenting with something you've never used before, say so. In all of those cases we'll be more than happy to provide guidance.

Just don't drop a scenario down here and wait for a complete solution on a silver platter.

I hope that all makes sense...
-craig

"You can never have too many knives" -- Logan Nine Fingers
jhansi
Participant
Posts: 33
Joined: Sat May 26, 2012 4:56 am

Post by jhansi »

i didn't notice that i am posting topics like that.
sorry for that.
here i want to mention one thing that, all posts i posted here are tried by me and some are not up to my knowledge.i am the beginner for datastage.
Actually i want to shorten the question for readability purpose.
so all posts posted by me are like that.after all i will consider your suggestion.
thnx
jhansi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Thank you for your reply and the explanation... and (hopefully) for taking my suggestions to heart.
jhansi wrote:Actually i want to shorten the question for readability purpose.
Please don't, we like to read! This generally falls into the Very Bad Idea category. One of the biggest problems we have here is when people fail to post enough information. We're then forced into a back-and-forth exchange where we have to ask questions that should have been answered in the initial post... have you tried this? What does X look like? etc etc. Best case it can be annoying, worst case the expression is "like pulling teeth". :wink:

As a general rule, post enough information to help us help you. Sometimes that means requirements spelled out in words rather than just input and output sample data and it always means tell us what you've tried so far or at least some idea how you think you should approach the problem. We'll take it from there!

Thanks for reading.

ps. I've unlocked your other questions.
Last edited by chulett on Thu Jun 21, 2012 7:25 am, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Now, as to your question, how familiar are you with the concept of stage variables? In my mind, the way to get the first X records from any group is to use stage variables to do group detection. Since they are evaulated from top to bottom, you can order them such that you can compare a current value to a previous value (say like deptno) and then decide what to do when it changes. At a high level:

Did the deptno change?

Yes - set counter to 1.
No - add 1 to counter.

Use the counter in the outgoing link's constraint, only allowing records where the count <= 2 to pass. Add in the standard warning for Parallel jobs about proper partitioning, in this case a hash partition on the deptno would be in order, that or run on a single node.
-craig

"You can never have too many knives" -- Logan Nine Fingers
srinivas.g
Participant
Posts: 251
Joined: Mon Jun 09, 2008 5:52 am

Post by srinivas.g »

Use aggregrator(to generate rank) --> filter (rec_count<=2)
Srinu Gadipudi
Post Reply