[英]How to concatenate multiple rows' fields in a sap hana table
I use SAP-HANA database. 我使用SAP-HANA数据库。 I have a simple 2 column table whose columns are id, name. 我有一个简单的2列表,其列为id,name。 The rows are these: 行是这些:
1 - tom
1 - harry
1 - jack
2 - larry
I would like to group the rows by the id, and concatenate the names into a field, and thus obtain this: 我想按id对行进行分组,并将名称连接到一个字段中,从而获得:
1 - tom, harry, jack
2 - larry
Can you please tell me how we can perform this operation in sap-hana? 能告诉我如何在sap-hana中执行此操作吗? Thanks in advance. 提前致谢。
If you are using HANA with revision 70, you can try this:- 如果您使用的是版本70的HANA,您可以尝试: -
SELECT ID, STRING_AGG(Name, ',') AS Names
FROM TAB
GROUP BY ID;
And for more info read this 有关更多信息,请阅读此内容
How to Concatenate Column Value from Multiple Rows into a Single Column? 如何将多行的列值连接成一列?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.