Search Postgresql Archives

Re: Where's the doc for "array()" — as in "select array(values (17), (42))"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/18/22 13:25, Bryn Llewellyn wrote:
I noticed that "array()" is used in the query that implements the "\du" psql meta-command. It has some similarity with "array_agg()" thus:

create temporary view x(v) as (values (17), (42));
select array_agg(v) from x;
select array(select v from x);

But there are differences. The "array()" function requires that its argument is a subquery that returns a single column. (Its data type can be composite.) But the "array_agg()" function's argument must be the select list in the larger context of a select statement—and in general together with "group by".


Lack of an explicit GROUP BY falls through to an implied one:

https://www.postgresql.org/docs/current/sql-select.html#SQL-GROUPBY

"If there are aggregate functions but no GROUP BY clause, the query is treated as having a single group comprising all the selected rows."


--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux