上面的sql给出了错误
解决方法 对于 the documentation:ERROR: in an aggregate with disTINCT,ORDER BY Expressions must appear in argument List
If disTINCT is specifIEd in addition to an order_by_clause,then all the ORDER BY Expressions must match regular arguments of the aggregate; that is,you cannot sort on an Expression that is not included in the disTINCT List.
所以试试吧
@H_403_7@select string_agg(distinct a || '-' || b,' order by a || '-' || b)from a_table;或在派生表中使用distinct:
@H_403_7@select string_agg(a || '-' || b,' order by a,b)from ( select distinct a,b from a_table ) s; 总结以上是内存溢出为你收集整理的postgresql – 当串联两列时,如何在字符串agg中添加顺序全部内容,希望文章能够帮你解决postgresql – 当串联两列时,如何在字符串agg中添加顺序所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)