如何在SAP HANA表中串联多个行的字段 [英] How to concatenate multiple rows' fields in a sap hana table

查看:482
本文介绍了如何在SAP HANA表中串联多个行的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SAP-HANA数据库.我有一个简单的2列表,其列为id,name.这些行是这些:

I use SAP-HANA database. I have a simple 2 column table whose columns are id, name. The rows are these:

1 - tom
1 - harry
1 - jack
2 - larry

我想按ID对行进行分组,并将名称连接到一个字段中,从而获得以下内容:

I would like to group the rows by the id, and concatenate the names into a field, and thus obtain this:

1 - tom, harry, jack
2 - larry

您能告诉我如何在SAP HANA中执行此操作吗?预先感谢.

Can you please tell me how we can perform this operation in sap-hana? Thanks in advance.

推荐答案

如果您使用的HANA版本为70,则可以尝试以下操作:-

If you are using HANA with revision 70, you can try this:-

SELECT ID, STRING_AGG(Name, ',')  AS Names
FROM TAB
GROUP BY ID;

有关更多信息,请阅读此内容

And for more info read this

如何将多行中的列值连接为单列?

这篇关于如何在SAP HANA表中串联多个行的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆