Re: Improve a query... - Mailing list pgsql-general

From Eric G. Miller
Subject Re: Improve a query...
Date
Msg-id 20010502180444.B4206@calico.local
Whole thread Raw
In response to Improve a query...  ("Eric G. Miller" <egm2@jps.net>)
List pgsql-general
On Wed, May 02, 2001 at 07:30:13PM +0200, Peter Eisentraut wrote:
> Eric G. Miller writes:
>
> > If max(period) for an organization yields the most recent reporting,
> > I want to get whatever is the most recent report for each organization.
>
> SELECT org_id, max(period) FROM reports GROUP BY org_id;

Naw, doesn't work. I need the other columns, so the GROUP BY is out
(except in a subselect).  The DISTINCT ON () syntax, though
non-standard, seems to do the job.

--
Eric G. Miller <egm2@jps.net>

pgsql-general by date:

Previous
From: Doug McNaught
Date:
Subject: Re: Ideal hardware configuration for pgsql
Next
From: "Dominic J. Eidson"
Date:
Subject: Re: Ideal hardware configuration for pgsql