PostgreSQL ARRAY_AGG 函数用于将包含null的输入值连接到数组中。
要了解 ARRAY_AGG 函数,请考虑将 COMPANY 记录为跟随-
testdb# select * from COMPANY; id | name | age | address | salary ----+-------+-----+-----------+-------- 1 | Paul | 32 | California| 20000 2 | Learnfk | 25 | Texas | 15000 3 | Teddy | 23 | Norway | 20000 4 | Mark | 25 | Rich-Mond | 65000 5 | David | 27 | Texas | 85000 6 | Kim | 22 | South-Hall| 45000 7 | James | 24 | Houston | 10000 (7 rows)
现在,基于上表,假设您要使用ARRAY_AGG,可以使用以下命令进行操作-
testdb=# SELECT ARRAY_AGG(SALARY) FROM COMPANY;
上面给出的PostgreSQL语句将产生以下输出-
array_agg --------------------------------------------- {20000,15000,20000,65000,85000,45000,10000}
参考链接
https://www.learnfk.com/postgresql/postgresql-array-functions.html
标签:PostgreSQL,AGG,COMPANY,无涯,20000,10000,ARRAY From: https://blog.51cto.com/u_14033984/8980035