Re: help with a view (join-query)

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: help with a view (join-query)
Дата
Msg-id 20060325235911.GA6265@wolff.to
обсуждение исходный текст
Ответ на help with a view (join-query)  (<me@alternize.com>)
Список pgsql-novice
On Fri, Mar 24, 2006 at 19:36:34 +0100,
  me@alternize.com wrote:
> hi list
>
> currently in our database, a "person" contains a relation to one or more "events". i now need a view where each
personis listed exactly once, and to each person only one (of possible more) events is listed. it does not matter which
onesof the events are shown. when doing a normal JOIN, the resultset might return more than one record per person (for
eachevent one line).  
> is there an easy way to build a query that fullfills my needs? i'd rather not check programmatically if i already
listedthe person or not. 

You could use the Postgres specific extension DISTINCT ON to do this. You can
even use ORDER BY to make which row you grab deterministic.

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

Предыдущее
От: John DeSoi
Дата:
Сообщение: Re: Bytea and perl
Следующее
От:
Дата:
Сообщение: Re: help with a view (join-query)