Received: from zombie.antar.bryansk.ru (zombie.antar.bryansk.ru [195.239.214.68]) by postgresql.org (Postfix) with ESMTP id 2684D47510B for ; Thu, 18 Apr 2002 19:27:54 -0400 (EDT) Received: (from fduch@localhost) by zombie.antar.bryansk.ru (8.11.3/8.11.3) id g3INUfY01437; Fri, 19 Apr 2002 03:30:41 +0400 (MSD) (envelope-from fduch) Date: Fri, 19 Apr 2002 03:30:41 +0400 From: Fduch the Pravking To: Albrecht Berger Cc: pgsql Subject: Re: DISTINCT ON ... without distinct null values ? Message-ID: <20020419033040.A1388@zombie.antar.bryansk.ru> References: <015d01c1e6e7$6abe3a10$a57ba8c0@wxp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <015d01c1e6e7$6abe3a10$a57ba8c0@wxp>; from berger1517@gmx.ch on Thu, Apr 18, 2002 at 04:43:25PM +0200 X-Archive-Number: 200204/236 X-Sequence-Number: 7500 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