Re: Non-aggregate values attached to aggregates?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Non-aggregate values attached to aggregates?
Дата
Msg-id 20041216220932.GA8143@winnie.fuhr.org
обсуждение исходный текст
Ответ на Non-aggregate values attached to aggregates?  (Benjamin Smith <lists@benjamindsmith.com>)
Ответы Re: Non-aggregate values attached to aggregates?
Список pgsql-general
On Thu, Dec 16, 2004 at 01:38:19PM -0800, Benjamin Smith wrote:

> I have a list of students, and a list of enrollment records, and I'm trying to
> get a list of students and their most recent enrollment/disenrollment dates.

If you don't mind using a non-standard construct, see the documentation
for SELECT DISTINCT ON.

http://www.postgresql.org/docs/7.4/static/queries-select-lists.html#QUERIES-DISTINCT
http://www.postgresql.org/docs/7.4/static/sql-select.html#SQL-DISTINCT

> Dates are kept as ]YYYYMMDD', eg 2004114 for Nov 14, 2004.

Why not use a DATE type?  You can reformat it with to_char() if
need be.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Non-aggregate values attached to aggregates?
Следующее
От: "Net Virtual Mailing Lists"
Дата:
Сообщение: tsearch2 avoiding firing of triggers.....