Re: GROUP BY and aggregate functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Henry House <hajhouse(at)houseag(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: GROUP BY and aggregate functions
Date: 2001-07-16 16:18:14
Message-ID: 7864.995300294@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Henry House <hajhouse(at)houseag(dot)com> writes:
> I only want the value of id for the row that matches max(postdate).

The standard-conforming way involves using a subselect, as someone
else already illustrated. A less standard but considerably faster
method is to use SELECT DISTINCT ON; there's an example in the
SELECT reference page.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Giorgio A. 2001-07-17 15:01:27 COUNT doesn't shows items with 0 occurrance
Previous Message Henry House 2001-07-16 15:53:07 Re: GROUP BY and aggregate functions