Re: Am I crazy or is this SQL not possible

Поиск
Список
Период
Сортировка
От maTKO
Тема Re: Am I crazy or is this SQL not possible
Дата
Msg-id 1149186541.453106.45070@i39g2000cwa.googlegroups.com
обсуждение исходный текст
Ответ на Am I crazy or is this SQL not possible  ("Collin Peters" <cadiolis@gmail.com>)
Список pgsql-sql
"Collin Peters" wrote:
> DISTINCT also doesn't work
>
> SELECT DISTINCT ON (email_broadcast_id) *
> FROM email_broadcast_history
> ORDER BY date_sent
>
> As you have to have the DISTINCT fields matching the ORDER BY fields.
> I have to ORDER BY date_sent, but I can't do a DISTINCT on date_sent

DISTINCT does work. You don't have to do DISTINCT on date_sent. The
left part of the ORDER BY must match the DISTINCT expression(s):

SELECT DISTINCT ON(broadcast_id) broadcast_id, date_sent, status FROM
table ORDER BY broadcast_id, date_sent DESC;



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Thomas Chille"
Дата:
Сообщение: Re: distinct aggregate with complex type dont see the equality operator [solved]
Следующее
От: "Aaron Bono"
Дата:
Сообщение: Re: Am I crazy or is this SQL not possible