More aggregate functions?

From: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: More aggregate functions?
Date: 2004-04-07 08:12:12
Message-ID: 4073B7DC.7090302@zara.6.isreserved.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2004-04-07 08:28:25 Re: PERFORM statement inside procedure
Previous Message Cyrille Gautard 2004-04-07 07:46:01 Informations about functions ...