pgsql--將一列多行數據合成一行顯示(逗號分隔)


使用array_agg(distinct(字段名)),array_to_string(字段名,',')

select array_to_string(array_agg(distinct(ele_table)),',') from entity_classification where code in ('1102010101','1102070800')

  

查詢結果:daohx_l,daohx_p,hl_a,hl_l


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM