Skip site navigation (1) Skip section navigation (2)

Re: help with a view (join-query)

From: <me(at)alternize(dot)com>
To: "Bruno Wolff III" <bruno(at)wolff(dot)to>
Cc: <pgsql-novice(at)postgresql(dot)org>
Subject: Re: help with a view (join-query)
Date: 2006-03-26 03:12:56
Message-ID: 02dd01c65083$2ec3f590$6402a8c0@iwing (view raw or flat)
Thread:
Lists: pgsql-novice
thanks alot - DISTINCT ON has exactly the behaviour i was looking for!

- thomas



----- Original Message ----- 
From: "Bruno Wolff III" <bruno(at)wolff(dot)to>
To: <me(at)alternize(dot)com>
Cc: <pgsql-novice(at)postgresql(dot)org>
Sent: Sunday, March 26, 2006 1:59 AM
Subject: Re: [NOVICE] help with a view (join-query)


> On Fri, Mar 24, 2006 at 19:36:34 +0100,
>  me(at)alternize(dot)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 person is listed exactly once, and 
>> to each person only one (of possible more) events is listed. it does not 
>> matter which ones of the events are shown. when doing a normal JOIN, the 
>> resultset might return more than one record per person (for each event 
>> one line).
>> is there an easy way to build a query that fullfills my needs? i'd rather 
>> not check programmatically if i already listed the 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.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
> 



In response to

pgsql-novice by date

Next:From: johnfDate: 2006-03-27 19:28:52
Subject: Does a connection support multiple transactions.
Previous:From: Bruno Wolff IIIDate: 2006-03-25 23:59:11
Subject: Re: help with a view (join-query)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group