Re: Feature Request, aggregate functions distinct on

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: luda posch <ludaludaluda(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Feature Request, aggregate functions distinct on
Date: 2011-04-26 22:33:24
Message-ID: 745.1303857204@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

luda posch <ludaludaluda(at)gmail(dot)com> writes:
> I am not an expert on the official sql spec, but I think it would be useful
> if distinct on() could be used within an aggregate when supplied with
> another column name. For example:

> select sum(distinct on(id) order_price) from order_table;
> select sum(distinct on(email_address) bounce_count) from email_bounces;
> select sum(distinct on(county) area) from state_county_area;

Use another level of sub-select, eg

select sum(order_price) from
(select distinct on(id) order_price from order_table ...) ss;

The usefulness of this doesn't really seem high enough to justify
inventing and maintaining a more compact way to handle it.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2011-04-26 22:59:24 Re: Feature Request, aggregate functions distinct on
Previous Message luda posch 2011-04-26 22:24:28 Feature Request, aggregate functions distinct on