Page 1 of 1

Find out first 2 records of each deptno?

Posted: Wed Jun 20, 2012 1:54 am
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

Posted: Wed Jun 20, 2012 7:12 am
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.

Posted: Wed Jun 20, 2012 9:21 am
by rameshrr3
A lot of clutter on the forum will be reduced if posts such as these are deleted or moved to Trash :)

Posted: Wed Jun 20, 2012 10:09 am
by mobashshar
I fully agree with you Criag.

Posted: Wed Jun 20, 2012 10:18 am
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...

Posted: Thu Jun 21, 2012 1:32 am
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

Posted: Thu Jun 21, 2012 7:19 am
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.

Posted: Thu Jun 21, 2012 7:24 am
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.

Posted: Thu Jun 21, 2012 2:45 pm
by srinivas.g
Use aggregrator(to generate rank) --> filter (rec_count<=2)