Re: Getting pk of the most recent row, in a group by - Mailing list pgsql-sql

From Rodrigo De León
Subject Re: Getting pk of the most recent row, in a group by
Date
Msg-id a55915760708131316t4ae9e506i3980e4ad87a8268c@mail.gmail.com
Whole thread Raw
In response to Getting pk of the most recent row, in a group by  (Bryce Nesbitt <bryce1@obviously.com>)
List pgsql-sql
On 8/13/07, Bryce Nesbitt <bryce1@obviously.com> wrote:
> In the second example, is it possible to get the primary key of the row
> with the minimum expires time?

SELECT   TYPE, MIN(expires), COUNT(*)      , (SELECT MIN(coupon_id)           FROM coupon          WHERE expires =
MIN(c.expires))AS coupon_id   FROM coupon c
 
GROUP BY TYPE;


pgsql-sql by date:

Previous
From: Ken Simpson
Date:
Subject: Re: Comparing two slices within one table efficiently
Next
From: Michael Glaesemann
Date:
Subject: Re: Getting pk of the most recent row, in a group by