Need to find sum(sal) for all the active employees

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

praveenk
Participant
Posts: 18
Joined: Sat Jan 15, 2011 11:31 am
Location: HYDERABAD

Need to find sum(sal) for all the active employees

Post by praveenk »

Hi,

i have a requirement of finding sum of salaries for all the active employees,
i'm finding it difficult with aggregator stage as it needs group by column where i do not need to group by, is there any other stage which supports me to get the required output.
Praveen
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Find or create a static value to group on.
-craig

"You can never have too many knives" -- Logan Nine Fingers
abhilashnair
Participant
Posts: 284
Joined: Fri Oct 13, 2006 4:31 am

Post by abhilashnair »

Aggregator will need a group by column. So you have to have one.
even for doing this outside DataStage by using a sql, uwill need a group by column
Vidyut
Participant
Posts: 24
Joined: Wed Oct 13, 2010 12:45 am

Post by Vidyut »

You must be having some column to filter out "active employees"
You can use the same column as your key in aggregator.
For Example: Status_Flag = 'Y'
praveenk
Participant
Posts: 18
Joined: Sat Jan 15, 2011 11:31 am
Location: HYDERABAD

Post by praveenk »

chulett wrote:Find or create a static value to group on.
please if you can explain me more clearly.
Praveen
Vidyut
Participant
Posts: 24
Joined: Wed Oct 13, 2010 12:45 am

Post by Vidyut »

Or If you don't have any such column and consider all rows in the table as active employees then you can just create one more temp column with any default value and the you can use it as your grouping column.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That would be the 'create' part I mentioned. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use a Column Generator stage to generate a constant (cycle with single value) and group by that.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
praveenk
Participant
Posts: 18
Joined: Sat Jan 15, 2011 11:31 am
Location: HYDERABAD

Post by praveenk »

I have created a static variable with a constant value in transformer and in aggregator ive grouped by that variable, now im getting the desired output but my question in performance perspective is this the best way?
Praveen
praveenk
Participant
Posts: 18
Joined: Sat Jan 15, 2011 11:31 am
Location: HYDERABAD

Post by praveenk »

How can i generate a constant value in column generator-- im setting properties as
-column method----> explicit
-column to generate --->col1

which is not giving the constant output, any help greatly appreciated
Praveen
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't have any way to check directly but it should be a 'Generate' option and the need to set it to something other than 'Cycle'... I think. Poke around and see if you can set it to generate a constant value... or perhaps cycle a number by 0? :?

And there's no "performance" problem with solving this using a transformer.
-craig

"You can never have too many knives" -- Logan Nine Fingers
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Click on the Output->Columns, then right-click on the generated column select Edit Row...

Generator->Algorithm

Choose your type. The algorithm types available vary depending on data type. For char/varchar and this job, I would choose Cycle and give it only one value to cycle through. The other type is Alphabet and you provide a string of characters for it to cycle through (again, for this job just enter one character). Other data types should be self-explanatory.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ah... there you go - cycle through one value. Thanks James.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I'm sure I specified "cycle with one value" earlier.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why, look at that... yes you did. Guess we should read your pithy replies once in a while. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply