Page 1 of 1

Aggregator stage

Posted: Tue Jun 27, 2006 5:28 am
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.

Re: Aggregator stage

Posted: Tue Jun 27, 2006 5:54 am
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.

Posted: Tue Jun 27, 2006 6:40 am
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.

Posted: Tue Jun 27, 2006 8:07 am
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