How to concatenate multiple rows' fields in a sap hana table

前端 未结 1 1411
陌清茗
陌清茗 2021-01-03 02:17

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
<
相关标签:
1条回答
  • 2021-01-03 02:55

    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

    How to Concatenate Column Value from Multiple Rows into a Single Column?

    0 讨论(0)
提交回复
热议问题