使用Sybase ASE 12.5.4并查找列出/ concat字符串值

时间:2018-10-19 14:58:56

标签: sql sybase sybase-ase

我有一个看起来像这样的表

enter image description here

我想创建一个查询,以便对第1列和第2列(tcbname和status)的相同值进行分组,第3列(scope_name)列出与该状态和tcb_name相关的所有范围。

以下是我的预期结果

| TUVAmerica, inc | | E | |<all the scope_name values that match first two column>|

1 个答案:

答案 0 :(得分:1)

在我看来您需要group_concat()

 select tcb_name ,status,
 group_concat(scope_name separator ',') as list_of_scope
 from your_table
 group by tcb_name,status