472,968 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,968 software developers and data experts.

More aggregate functions?

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

Nov 23 '05 #1
5 3665
* David Garamond (li***@zara.6.isreserved.com) wrote:
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) [...] 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/.


There's an example of GROUP_CONCAT already in the mailing lists but
a more obvious place, linked from the documentation, would be really
nice. Having the functions included in the main distribution would be
nice too, of course. :) I'd be happy to host such a page if necessary
but I really think it'd be better on postgresql.org and linked in from
the documentation as 'other non-standard/extra functions' or some such.
What can we do to make this happen?

Stephen

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAc+wcrzgMPqB3kigRAlutAJ9/LfhBDdNSPThfUu1zT6j/RH4YYACfZmsf
pbRuY0NGZhylC6EGaoh2jUk=
=nbn8
-----END PGP SIGNATURE-----

Nov 23 '05 #2
David Garamond <li***@zara.6.isreserved.com> writes:
What do people think of adding some more aggregate functions. These are
the ones that MySQL has and PG doesn't: - STD/STDDEV
- VARIANCE
Have you read the documentation lately?
- BIT_OR
- BIT_AND
- GROUP_CONCAT (for strings, added in MySQL 4.x)


Unless these are doing something I don't see, they should be easily
writable using CREATE AGGREGATE.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #3
stddev and variance are available for both float8 and
numeric datatypes.
David Garamond <li***@zara.6.isreserved.com> writes:
What do people think of adding some more aggregate functions. These are
the ones that MySQL has and PG doesn't:


- STD/STDDEV
- VARIANCE


--
P. J. "Josh" Rovero Sonalysts, Inc.
Email: ro****@sonalysts.com www.sonalysts.com 215 Parkway North
Work: (860)326-3671 or 442-4355 Waterford CT 06385
************************************************** *********************

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #4
* Tom Lane (tg*@sss.pgh.pa.us) wrote:
- BIT_OR
- BIT_AND
- GROUP_CONCAT (for strings, added in MySQL 4.x)


Unless these are doing something I don't see, they should be easily
writable using CREATE AGGREGATE.


It'd be nice to have a place to put functions that people have written
and found useful but that aren't part of the base. Even nicer would be
to have this place be on postgresql.org and linked to from the
documentation. I havn't needed BIT_OR or BIT_AND before but I've used
the GROUP_CONCAT-type aggregate a couple of times. The first time I
wanted that function it took me a while to find (though eventually I did
in the mailing lists somewhere).

Stephen

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAdCd4rzgMPqB3kigRAlMeAJ9JTu5fTIKDItHrZe1Hmn RFi/mpywCfbor7
bv47AP1E7Tw5/0uF/MWNjkI=
=4H5s
-----END PGP SIGNATURE-----

Nov 23 '05 #5
Stephen Frost <sf****@snowman.net> writes:
It'd be nice to have a place to put functions that people have written
and found useful but that aren't part of the base.


Agreed. The "Postgres Cookbook" site used to do some of that, but
I don't think it's been maintained lately. Right now I'd say
techdocs.postgresql.org is the most likely candidate for housing a
collection of small functions of this sort.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ariel Jakobovits | last post by:
I have a table with 2 primary keys, one is a foreign key, the other is produced by a sequence. I want to SELECT query for one record that has a list of the sequence-produced values for all...
1
by: Job Lot | last post by:
Is it possible to use Aggregate functions with GROUP BY Clauses on DataTable. I have a DataTable with following values: Date Amount Int Balance 1/1/2004 5000.00 50.00 5050.00...
15
by: Dave | last post by:
Has anyone encountered the error message "Can not open any more databases" and what did you do to solve it? Thanks, Dave
10
by: neb | last post by:
Dear member of the forum, Ms access has built-in aggregate function like: -Sum, Max, First, Avg, ... Is it possible to build user-defined aggregate? (if you have any clue, do not hesitate to...
3
by: S P Arif Sahari Wibowo | last post by:
Hi! I would like to make an editable continous form, where most fields will be from table A and editable, except 1-3 fields are a glimpse into table B and uneditable. Table A relate to table B...
8
by: jefftyzzer | last post by:
The current issue of "Oracle Magazine" has an article on creating custom aggregate functions, which naturally got me thinking about how to do this in DB2. I found some articles on creating...
5
by: Dean | last post by:
Has anyone toiled with creating/using alternate domain aggregate functions? I have been messing with that a little. The one recordsource I have been working indicates I get 20 to 40% savings in...
0
by: BillCo | last post by:
just wasted a long time figuring out this and I figure if I post it might save someone some pain! Jet (DAO) will allow you to to use nested aggregate functions like building blocks, e.g.: ...
5
by: BillCo | last post by:
I just wasted a long time figuring out this and I figure if I post it might save someone some pain! Jet (DAO) will allow you to to use nested aggregate functions like building blocks, e.g.: ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.