pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
DISTINCT ON ... without distinct null values ?
2+ messages / 2 participants
[nested] [flat]

* DISTINCT ON ... without distinct null values ?
@ 2002-04-18 14:43  Albrecht Berger <berger1517@gmx.ch>
  0 siblings, 1 reply; 2+ messages in thread

From: Albrecht Berger @ 2002-04-18 14:43 UTC (permalink / raw)
  To: pgsql-sql

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 !

Does anybody has an idea ?

Thx
Albrecht








^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: DISTINCT ON ... without distinct null values ?
@ 2002-04-18 23:30  Fduch the Pravking <fduch@antar.bryansk.ru>
  parent: Albrecht Berger <berger1517@gmx.ch>
  0 siblings, 0 replies; 2+ messages in thread

From: Fduch the Pravking @ 2002-04-18 23:30 UTC (permalink / raw)
  To: Albrecht Berger <berger1517@gmx.ch>; +Cc: 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2002-04-18 23:30 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-04-18 14:43 DISTINCT ON ... without distinct null values ? Albrecht Berger <berger1517@gmx.ch>
2002-04-18 23:30 ` Fduch the Pravking <fduch@antar.bryansk.ru>

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