Re: Improve a query...

Поиск
Список
Период
Сортировка
От Eric G. Miller
Тема Re: Improve a query...
Дата
Msg-id 20010502180444.B4206@calico.local
обсуждение исходный текст
Ответ на Improve a query...  ("Eric G. Miller" <egm2@jps.net>)
Список 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 по дате отправления:

Предыдущее
От: Doug McNaught
Дата:
Сообщение: Re: Ideal hardware configuration for pgsql
Следующее
От: "Dominic J. Eidson"
Дата:
Сообщение: Re: Ideal hardware configuration for pgsql