Re: Problem with aggregate functions and GROUP BY

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Alex Page" <alex(dot)page(at)solid-state-logic(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem with aggregate functions and GROUP BY
Date: 2001-08-08 17:26:47
Message-ID: 2091.997291607@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Alex Page" <alex(dot)page(at)solid-state-logic(dot)com> writes:
> I'm trying to write a query that returns the rows containing the
> most recent values for each foreign key.

The best way to do this (on every dimension except portability :-()
is SELECT DISTINCT ON. See the weather-report example in the SELECT
reference page.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 2001-08-08 17:50:52 Re: REFERENCES constraint
Previous Message Grigoriy G. Vovk 2001-08-08 17:26:33 Re: REFERENCES constraint