| От | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера