pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fduch the Pravking <fduch@antar.bryansk.ru>
To: Albrecht Berger <berger1517@gmx.ch>
Cc: pgsql <pgsql-sql@postgresql.org>
Subject: Re: DISTINCT ON ... without distinct null values ?
Date: Fri, 19 Apr 2002 03:30:41 +0400
Message-ID: <20020419033040.A1388@zombie.antar.bryansk.ru> (raw)
In-Reply-To: <015d01c1e6e7$6abe3a10$a57ba8c0@wxp>
References: <015d01c1e6e7$6abe3a10$a57ba8c0@wxp>

On Thu, Apr 18, 2002 at 04:43:25PM +0200, Albrecht Berger wrote:
> Hello,
> I've got a table which I query with something like " SELECT DISTINCT ON("c")
> FROM table ... " .
> 
> Not every row in the column "c" does have a value, some are null.
> My problem is, that I want to eliminate double values in "c" only if they
> are not null !

CREATE SEQUENCE tmp_seq;
SELECT DISTINCT ON (COALESCE("c", nextval('tmp_seq')) * FROM table ...
DROP SEQUENNCE tmp_seq;

or even

SELECT DISTINCT ON (COALESCE("c", random())) * FROM table ...

Not sure I'm right...

-- 
Fduch M. Pravking



view thread (2+ messages)

Message-ID: <20020419033040.A1388@zombie.antar.bryansk.ru>
Permalink:  ../20020419033040.A1388@zombie.antar.bryansk.ru/
Also on:    postgresql.org/message-id/20020419033040.A1388@zombie.antar.bryansk.ru

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: fduch@antar.bryansk.ru, berger1517@gmx.ch
  Subject: Re: DISTINCT ON ... without distinct null values ?
  In-Reply-To: <20020419033040.A1388@zombie.antar.bryansk.ru>

* 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