X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C95E53A4495 for ; Tue, 26 Oct 2004 21:50:08 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33507-09 for ; Tue, 26 Oct 2004 20:49:50 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id CB8673A2BC1 for ; Tue, 26 Oct 2004 21:49:50 +0100 (BST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id E8EDF350CA; Tue, 26 Oct 2004 13:48:48 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id E76D1350BF; Tue, 26 Oct 2004 13:48:48 -0700 (PDT) Date: Tue, 26 Oct 2004 13:48:48 -0700 (PDT) From: Stephan Szabo To: Wei Weng Cc: pgsql-sql@postgresql.org Subject: Re: How do you compare (NULL) and (non-NULL)? In-Reply-To: <417EB238.1000109@kencast.com> Message-ID: <20041026134508.N5021@megazone.bigpanda.com> References: <417EB238.1000109@kencast.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/189 X-Sequence-Number: 19292 On Tue, 26 Oct 2004, Wei Weng wrote: > In the following query > > SELECT Parent FROM Channels ORDER BY Parent ASC; > > If I have a couple of (NULL)s in the field [Parent], they will be listed at > the bottom of the query result. > > Is it because PostgreSQL considers (NULL) as the biggest value? If I run the > same query under MSSQL Server 2000, I get the exact opposite result > regarding the order of (NULL)s and (non-NULL) values. They are listed at the > very beginning of the query result. The spec basically says (IIRC) that implementations must either treat all nulls as greater than all non-nulls for ordering or less than all non-nulls for ordering, but that different implementations may choose different choices. I think the most recent version (at least) provides an option to specify which way to handle nulls, but we don't support that as far as I know.