Search Postgresql Archives

More aggregate functions?

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

 



What do people think of adding some more aggregate functions. These are the ones that MySQL has and PG doesn't:

- STD/STDDEV
- VARIANCE
- BIT_OR
- BIT_AND
- GROUP_CONCAT (for strings, added in MySQL 4.x)

Particularly, I find GROUP_CONCAT practical to quickly display 1-many relationship, e.g.:

 CREATE TABLE mommy (
   id INT PRIMARY KEY,
   name TEXT);
 CREATE TABLE child (
   id INT PRIMARY KEY,
   mommy_id INT REFERENCES(mommy(id)),
   name TEXT
 );

 SELECT
   mommy.name as mommy,
   GROUP_CONCAT(child.name SEPARATOR ", ") as children
 FROM mommy, child
 GROUP BY mommy.id;

would result in:

 mommy         children
 -----         -----------------
 dot           ellen, catherine
 cate          bridget, kerry, rory
 rachel        emma

Btw, I have written 1 or 2 of the above myself with CREATE AGGREGATE. But perhaps it would be nice if it's available as a builtin function or at least present in contrib/.

--
dave


---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

[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 Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux