cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

equivalent for LISTAGG function for HANA

Former Member
0 Kudos
4,813

Hi all,

I am trying to find an equivalent for LISTAGG to execute on HANA. However, I have not achieved it so far. An example can be found below.

SELECT deptno,

LISTAGG(ename, ',') WITHIN GROUP (ORDER BY ename) AS employees

FROM  emp

GROUP  BY

deptno;


    DEPTNO EMPLOYEES

---------- ------------------------------------------------------------
        10 CLARK,KING,MILLER
        20 ADAMS,FORD,JONES,SCOTT,SMITH
        30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD

3 rows selected.

I have also tried to implement it by using functions. However, as far as I see we can't use nvarchar input/output for user defined scalar functions. And it is also not possible to use procedures in a `select` statement.

What do you advice? An example would be great

Thanks in advance,

Cagdas

View Entire Topic
roland_mallmann
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

as Martin already mentioned, it is called STRING_AGG and has been made available from Revision 71 onwards.

Kind regards,

Roland

former_member182302
Active Contributor
0 Kudos

Hi Roland,

Did you get a chance to test it?Am on revision 71 but that function is still unavailable for me?

Regards,

Krishna Tangudu

roland_mallmann
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Krishna,

just tested vs Revision 72 and it works there.

It came in with Revision 71.

Thanks,

Roland

P.S.: again, make sure you use STRING_AGG instead of LISTAGG

former_member182302
Active Contributor
0 Kudos

Thanks for the update Roland.

Regards,

Krishna Tangudu