How to sort the result from string_agg()

前端 未结 3 1777
旧巷少年郎
旧巷少年郎 2020-12-24 04:01

I have a table:

CREATE TABLE tblproducts
(
productid integer,
product character varying(20)
)

With the rows:

INSERT INTO tb         


        
3条回答
  •  悲哀的现实
    2020-12-24 04:38

    With postgres 9.0+ you can write:

    select string_agg(product,' | ' order by product) from "tblproducts"
    

    Details here.

提交回复
热议问题