Re: Getting pk of the most recent row, in a group by

Поиск
Список
Период
Сортировка
От Rodrigo De León
Тема Re: Getting pk of the most recent row, in a group by
Дата
Msg-id a55915760708131316t4ae9e506i3980e4ad87a8268c@mail.gmail.com
обсуждение исходный текст
Ответ на Getting pk of the most recent row, in a group by  (Bryce Nesbitt <bryce1@obviously.com>)
Список 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 по дате отправления:

Предыдущее
От: Ken Simpson
Дата:
Сообщение: Re: Comparing two slices within one table efficiently
Следующее
От: Michael Glaesemann
Дата:
Сообщение: Re: Getting pk of the most recent row, in a group by