Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group