Re: Problem with aggregate functions and GROUP BY - Mailing list pgsql-sql

From Tom Lane
Subject Re: Problem with aggregate functions and GROUP BY
Date
Msg-id 2091.997291607@sss.pgh.pa.us
Whole thread Raw
In response to Problem with aggregate functions and GROUP BY  ("Alex Page" <alex.page@solid-state-logic.com>)
List pgsql-sql
"Alex Page" <alex.page@solid-state-logic.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


pgsql-sql by date:

Previous
From: "Grigoriy G. Vovk"
Date:
Subject: Re: REFERENCES constraint
Next
From: "Grigoriy G. Vovk"
Date:
Subject: Re: Functions returning more than one value