Re: count (DISTINCT expression [ , ... ] ) and documentation

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Ivan Sergio Borgonovo" <mail(at)webthatworks(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: count (DISTINCT expression [ , ... ] ) and documentation
Date: 2008-12-26 15:23:52
Message-ID: 162867790812260723i50513f69u5422cfe350739e9e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2008/12/26 Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>:
> On Fri, 26 Dec 2008 15:46:48 +0100
> "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> wrote:
>
>> count has only one argument,
>
> then what was changed between 8.1 and 8.2 to change the docs?
> None of the functions listed in:
> http://www.postgresql.org/docs/8.2/static/functions-aggregate.html
> seems to support
> aggregate(distinct exp [,exp])

http://www.postgresql.org/docs/8.2/interactive/functions-aggregate.html

http://www.postgresql.org/docs/8.2/interactive/functions-aggregate.html#FUNCTIONS-AGGREGATE-STATISTICS-TABLE

>
> Does the change reflect the change in the possibility to write user
> defined aggregates that support more then one distinct expression?

CREATE AGGREGATE name ( input_data_type [ , ... ] ) (
SFUNC = sfunc,
STYPE = state_data_type
[ , FINALFUNC = ffunc ]
[ , INITCOND = initial_condition ]
[ , SORTOP = sort_operator ]
)

you are able to write multi param aggregates.

regards
Pavel Stehule

>
> The first thing that comes to my mind to emulate
> count(distinct a,b)
> would be to
>
> create table test.dist (a int, b int);
> insert into test.dist values(1,0);
> insert into test.dist values(1,0);
> insert into test.dist values(1,1);
> insert into test.dist values(0,0);
> select count(*) from (select distinct a,b from test.dist ) a;
>
> but still I can't think of anything that would work with
> aggregate(distinct a,b)
> not just count.
>
> --
> Ivan Sergio Borgonovo
> http://www.webthatworks.it
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2008-12-26 16:46:42 Re: This is a limit-offset bug?
Previous Message Ivan Sergio Borgonovo 2008-12-26 15:06:00 Re: count (DISTINCT expression [ , ... ] ) and documentation