Aggregator stage

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
rafidwh
Participant
Posts: 179
Joined: Mon Oct 10, 2005 11:30 pm

Aggregator stage

Post by rafidwh »

Hi All,
My requirement is
source is oci and looks
empno ename dept sal
1 A 1 5
2 B 1 10
3 C 2 10
4 D 3 5
5 E 2 10

I need to get total sal by grouping dept using aggregator and my data should look like

empno ename dept sal
1 A 1 15
2 B 1 15
3 C 2 20
4 D 3 5
5 E 2 20

Any suggestions please

Thanks in advance
Saik.
vijayrc
Participant
Posts: 197
Joined: Sun Apr 02, 2006 10:31 am
Location: NJ

Re: Aggregator stage

Post by vijayrc »

rafidwh wrote:Hi All,
My requirement is
source is oci and looks
empno ename dept sal
1 A 1 5
2 B 1 10
3 C 2 10
4 D 3 5
5 E 2 10

I need to get total sal by grouping dept using aggregator and my data should look like

empno ename dept sal
1 A 1 15
2 B 1 15
3 C 2 20
4 D 3 5
5 E 2 20

Any suggestions please

Thanks in advance
Saik.
In this case, DEPT will be the key, for which the Salaray accumulation needs to be done. So the output of Aggregator can only be DEPT / SALARY-TOTAL. You may need a Lookup with this file for the pattern you may need. Hope this helps.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Group by the third column, do a sum on the salary by either using an aggregator stage or you do this even in the sql select. Let this go into a hashed file keyed on dept.
You source will be the exact same source, do a lookup on your hashed file that contains aggregated data to get the nature of your output.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

You can use your user defined select query as

Code: Select all

select a.empno, a.ename , a.dept , (select sum(b.sal) from tablename b where a.dept = b.dept group by b.dept) As SAL from tablename a
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
Post Reply