Re: Grouping, Aggregate, Min, Max

From: Misa Simic <misa(dot)simic(at)gmail(dot)com>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Grouping, Aggregate, Min, Max
Date: 2013-12-16 15:26:36
Message-ID: CAH3i69m+2mttsU0SF+P360byNJLgB1dhGg+TKQBHNMtGuG0hXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2013/12/13 Kevin Grittner <kgrittn(at)ymail(dot)com>

> Misa Simic <misa(dot)simic(at)gmail(dot)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

Many thanks Kevin! :)

It simply works - perfect! :)

Many thanks,

Misa

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2013-12-16 17:32:28 Re: pg_stat_tmp
Previous Message Merlin Moncure 2013-12-16 14:47:20 Re: replacing expresion in plpgsql