MySQL中group_concat()在PostgreSQL中的实现

MySQL中经常使用到GROUP_CONCAT()这个函数,在Pg中可以通过数组来实现:


pgd=# create aggregate group_concat (anyelement)

(

sfunc = array_append,

stype = anyarray,

initcond='{}'

);


这样句式结构可以和MySQL的一样:

SELECT userid,group_concat(book_count) as bcn FROM book_test_table ;

你可能感兴趣的:(mysql,PostgreSQL)