Re: Sorting by NULL values

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Ian Burrell <ib(at)onsitetech(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Sorting by NULL values
Date: 2003-03-04 20:13:05
Message-ID: 20030304120713.W55865-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Oleg Bartunov 2003-03-04 20:13:20 Re: Gist indexes on int arrays
Previous Message Greg Stark 2003-03-04 20:10:23 Re: Forcing query to use an index