Re: Grouping, Aggregate, Min, Max - Mailing list pgsql-general

From Kevin Grittner
Subject Re: Grouping, Aggregate, Min, Max
Date
Msg-id 1386965620.18832.YahooMailNeo@web162902.mail.bf1.yahoo.com
Whole thread Raw
In response to Grouping, Aggregate, Min, Max  (Misa Simic <misa.simic@gmail.com>)
Responses Re: Grouping, Aggregate, Min, Max
List pgsql-general
Misa Simic <misa.simic@gmail.com> wrote:

> So I wonder - is there some kind of aggregate window function
> what does desired results?

Not built in, but PostgreSQL makes it pretty easy to do so.  With a
little effort to define your own aggregate function, your query can
look like this:

SELECT
    thing_id,
    category,
    int4range_list(period_id)
  FROM thing
  GROUP BY thing_id, category
  ORDER BY 1, 2;

I've attached a couple files -- one which creates the desired
aggregate function, and the other loads a table with two of your
sample data sets and runs the above.  This is just intended as a
quick example of the capabilities available to you.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachment

pgsql-general by date:

Previous
From: salah jubeh
Date:
Subject: Re: design for multiple time series
Next
From: Victor Yegorov
Date:
Subject: Unexpected update behaviour