Search Postgresql Archives

Re: Feature Request, aggregate functions distinct on

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



luda posch <ludaludaluda@xxxxxxxxx> 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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux