pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAggregate
3+ messages / 3 participants
[nested] [flat]
* Aggregate
@ 1998-05-26 13:12 Aleksey Dashevsky <postgres@luckynet.co.il>
0 siblings, 0 replies; 3+ messages in thread
From: Aleksey Dashevsky @ 1998-05-26 13:12 UTC (permalink / raw)
To: pgsql-sql
hi!
Just curious: how could I create an aggregate that match to any postgresql
type (something like "count")?
Thanks
Al.
^ permalink raw reply [nested|flat] 3+ messages in thread
* aggregate...
@ 2002-05-14 16:13 Mathieu Arnold <mat@mat.cc>
0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Arnold @ 2002-05-14 16:13 UTC (permalink / raw)
To: pgsql-sql
Hi
I have this :
CREATE FUNCTION "comma_cat" (text,text) RETURNS text AS '
SELECT CASE WHEN $2 IS NULL OR $2 = '''' THEN $1
WHEN $1 IS NULL OR $1 = '''' THEN $2
ELSE $1 || '', '' || $2
END
' LANGUAGE 'sql';
CREATE AGGREGATE list ( BASETYPE = text, SFUNC = comma_cat, STYPE = text,
INITCOND = '' );
I can use it as :
select user, list(email) from user join email using (id_user);
user | list
-------+-----------------------------
mat | mat@mat.cc, mat@absolight.fr
isa | isa@mat.cc
but now, I'd like a better version of this function/aggregate couple which
would allow me to do something like :
select user, list(email, ',') from user join email using (id_user);
user | list
-------+-----------------------------
mat | mat@mat.cc,mat@absolight.fr
isa | isa@mat.cc
or :
select user, list(email, '|') from user join email using (id_user);
user | list
-------+-----------------------------
mat | mat@mat.cc|mat@absolight.fr
isa | isa@mat.cc
I know I'd have to modify the function to take a third argument (easy) but
I don't know how to use a 2 argument aggregate (I don't even know if it's
possible).
--
Mathieu Arnold
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: aggregate...
@ 2002-05-14 20:13 Tom Lane <tgl@sss.pgh.pa.us>
parent: Mathieu Arnold <mat@mat.cc>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2002-05-14 20:13 UTC (permalink / raw)
To: Mathieu Arnold <mat@mat.cc>; +Cc: pgsql-sql
Mathieu Arnold <mat@mat.cc> writes:
> I don't know how to use a 2 argument aggregate (I don't even know if it's
> possible).
We don't have any support for multi-argument aggregates. I don't think
it's impossible to do, but it would take some hacking.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2002-05-14 20:13 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-05-26 13:12 Aggregate Aleksey Dashevsky <postgres@luckynet.co.il>
2002-05-14 16:13 aggregate... Mathieu Arnold <mat@mat.cc>
2002-05-14 20:13 ` Re: aggregate... Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox