X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 40ACC4789ED for ; Tue, 4 Mar 2003 16:36:53 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 24260-05 for ; Tue, 4 Mar 2003 16:36:48 -0500 (EST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 58864478A3B for ; Tue, 4 Mar 2003 15:13:05 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id C6A63D615; Tue, 4 Mar 2003 12:13:05 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id B85AA5C04; Tue, 4 Mar 2003 12:13:05 -0800 (PST) Date: Tue, 4 Mar 2003 12:13:05 -0800 (PST) From: Stephan Szabo To: Ian Burrell Cc: Subject: Re: Sorting by NULL values In-Reply-To: <3E65023E.10404@onsitetech.com> Message-ID: <20030304120713.W55865-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/136 X-Sequence-Number: 12176 On Tue, 4 Mar 2003, Ian Burrell wrote: > I am doing a query where I need to sort by a column that may be NULL > because it is coming from an OUTER JOIN. I noticed a difference between > PostgreSQL and other databases about where NULLs show up. It seems that > with Postgres, NULLs are sorted after other values. Other databases > sort them before. > Is there any standard on how sorting NULLs work? Is there a way to IIRC, they're either considered greater than or less than non-NULL values, but the decision is up to the implementation. > change Postgres's behavior? Is there a way to replace the NULLs with > empty strings? Coalesce should work.