pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: pgsql@peope.net
To: pgsql-sql@postgresql.org
Subject: DISTINCT ON () with UNION
Date: Sun, 13 May 2001 23:14:04 GMT
Message-ID: <20010513.23140422@mis.configured.host> (raw)

How can you use a distinct on () including the whole union.

eg

select distinct on (valutaid) valutaid, short from valuta UNION select 
landid, land from land order by valutaid;

table: valuta
valutaid	valuta
1		USD
2		SEK

table: land
landid	land
1		Sweden
2		USA
3		Norway

The above would give
1	USD
1	Sweden
2	SEK
2	USA
3	Norway

What I would like to get is
1	USD
2	SEK
3	Norway

I did specify distinct on (valutaid) anyways =)

Any suggestions?

Best regards
Per-Olof Pettersson



view thread (2+ messages)  latest in thread

Message-ID: <20010513.23140422@mis.configured.host>
Permalink:  ../20010513.23140422@mis.configured.host/
Also on:    postgresql.org/message-id/20010513.23140422@mis.configured.host

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: pgsql@peope.net
  Subject: Re: DISTINCT ON () with UNION
  In-Reply-To: <20010513.23140422@mis.configured.host>
  References: <20010513.23140422@mis.configured.host>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox