More aggregate functions? - Mailing list pgsql-general

From David Garamond
Subject More aggregate functions?
Date
Msg-id 4073B7DC.7090302@zara.6.isreserved.com
Whole thread Raw
Responses Re: More aggregate functions?
Re: More aggregate functions?
List pgsql-general
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


pgsql-general by date:

Previous
From: Cyrille Gautard
Date:
Subject: Informations about functions ...
Next
From: Richard Huxton
Date:
Subject: Re: PERFORM statement inside procedure