How to sort the result from string_agg()
问题 I have a table: CREATE TABLE tblproducts ( productid integer, product character varying(20) ) With the rows: INSERT INTO tblproducts(productid, product) VALUES (1, 'CANDID POWDER 50 GM'); INSERT INTO tblproducts(productid, product) VALUES (2, 'SINAREST P SYP 100 ML'); INSERT INTO tblproducts(productid, product) VALUES (3, 'ESOZ D 20 MG CAP'); INSERT INTO tblproducts(productid, product) VALUES (4, 'HHDERM CREAM 10 GM'); INSERT INTO tblproducts(productid, product) VALUES (5, 'CREAM 15 GM');