From: Rod Taylor <rbt@rbt.ca>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: Ian Burrell <ib@onsitetech.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Sorting by NULL values
Date: 04 Mar 2003 17:01:59 -0500
Message-ID: <1046815319.15229.87.camel@jester> (raw)
In-Reply-To: <20030304120713.W55865-100000@megazone23.bigpanda.com>
References: <20030304120713.W55865-100000@megazone23.bigpanda.com>
On Tue, 2003-03-04 at 15:13, Stephan Szabo wrote:
> 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
If you care, order by their boolean equivelent first:
order by field is null desc, field
DESC puts nulls first, since true > false
> 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.
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
--
Rod Taylor <rbt@rbt.ca>
PGP Key: http://www.rbt.ca/rbtpub.ascAttachments:
signature.asc (application/pgp-signature, 186B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rbt@rbt.ca, sszabo@megazone23.bigpanda.com, ib@onsitetech.com
Subject: Re: Sorting by NULL values
In-Reply-To: <1046815319.15229.87.camel@jester>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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