Re: DISTINCT ON ... without distinct null values ?

From: Fduch the Pravking <fduch(at)antar(dot)bryansk(dot)ru>
To: Albrecht Berger <berger1517(at)gmx(dot)ch>
Cc: pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: DISTINCT ON ... without distinct null values ?
Date: 2002-04-18 23:30:41
Message-ID: 20020419033040.A1388@zombie.antar.bryansk.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Roberto Mello 2002-04-19 01:41:51 Re: [DOCS] [GENERAL] Migrating Oracle to PostgreSQL
Previous Message Jan Wieck 2002-04-18 18:49:26 Re: call the same pl/pgsql procedure twice in the same connection