Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
I am trying to do cumulative strings but not able to solve. Could anyone please help me to solve this issue.
Consider the following as the Source data :
DEPTNO | ENAME |
20 | G |
10 | A |
10 | D |
20 | E |
10 | B |
10 | C |
20 | F |
20 | H |
The result should be as follows:
DEPTNO ENAME_LIST
10 | A |
10 | A,B |
10 | A,B,C |
10 | A,B,C,D |
20 | E |
20 | E,F |
20 | E,F,G |
20 | E,F,G,H |
Thanks and Regards,
Gayathri Devi.
A bit more simplified code:
temp1: LOAD * INLINE [ DEPTNO, ENAME 20, G 10, A 10, D 20, E 10, B 10, C 20, F 20, H ]; temp2: LOAD DEPTNO, If(DEPTNO=Peek(DEPTNO), Peek(NewEname)&','&ENAME, ENAME) as NewEname Resident temp1 Order by DEPTNO, ENAME ASC; Drop Table temp1;
Hey there,
Your script should look like this:
A bit more simplified code:
temp1: LOAD * INLINE [ DEPTNO, ENAME 20, G 10, A 10, D 20, E 10, B 10, C 20, F 20, H ]; temp2: LOAD DEPTNO, If(DEPTNO=Peek(DEPTNO), Peek(NewEname)&','&ENAME, ENAME) as NewEname Resident temp1 Order by DEPTNO, ENAME ASC; Drop Table temp1;
Hi,
Thanks for your reply.
Thanks and Regards,
Gayathri