小弟在哦進行資料整理,需要將分組后同組某一列資料組合成一行顯示,于是用到了string_agg函式,但發現此函式無法去去重后續在合并,有別的好方法嗎?
select id,string_agg(distinct (姓名),“/”)
from 學生
group by 班級
uj5u.com熱心網友回復:
select id,string_agg(姓名,“/”)from(
select distintct xxxx
from 學生
group by 班級
)data
uj5u.com熱心網友回復:
select id, array_to_string(array_agg(distinct 姓名),'/')from 學生
group by 班級
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/90557.html
標籤:疑難問題
