Re: Improve a query...

From: "Eric G(dot) Miller" <egm2(at)jps(dot)net>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Improve a query...
Date: 2001-05-03 01:04:44
Message-ID: 20010502180444.B4206@calico.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)jps(dot)net>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message guard 2001-05-03 01:14:29 Not make
Previous Message GH 2001-05-03 00:53:21 Re: Ideal hardware configuration for pgsql