Re: How can I get the last element out of GROUP BY sets?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Creager <Robert_Creager(at)LogicalChaos(dot)org>
Cc: PGSQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How can I get the last element out of GROUP BY sets?
Date: 2004-01-19 05:44:30
Message-ID: 20989.1074491070@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Robert Creager <Robert_Creager(at)LogicalChaos(dot)org> writes:
> ... one piece of data I need is the last value for each GROUP BY
> period. Alas, I cannot figure out how to do this.

SELECT DISTINCT ON (rather than GROUP BY) could get this done for you.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-01-19 06:20:03 Re: DROP TRIGGER
Previous Message Tom Lane 2004-01-19 05:40:33 Re: Execute permissions for stored functions