teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

訂正

2019/06/28 12:13

投稿

sazi
sazi

スコア25430

answer CHANGED
@@ -2,7 +2,7 @@
2
2
  ```SQL
3
3
  with test as (
4
4
  select name, count(*) cnt
5
- , array_to_string(array_agg(tag),',') tag_list
5
+ , array_to_string(array_agg(distinct tag order by tag),',') tag_list
6
6
  from TABLE_X
7
7
  group by name
8
8
  )
@@ -13,4 +13,5 @@
13
13
  ,(select tag_list from test where name='B') B_tag_list
14
14
  ,(select cnt from test where name='C') C_COUNT
15
15
  ,(select tag_list from test where name='C') C_tag_list
16
- ```
16
+ ```
17
+ ※パターンを集約せず列挙する場合は、distinctを外して下さい