Re: ORDER BY and null values - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: ORDER BY and null values
Date
Msg-id 20020710154721.GA3981@wolff.to
Whole thread Raw
In response to ORDER BY and null values  (Paulo Jan <admin@digital.ddnet.es>)
List pgsql-general
On Wed, Jul 10, 2002 at 14:04:32 +0200,
  Paulo Jan <admin@digital.ddnet.es> wrote:
> Hi all:
>
>     Sorry if this has been asked before. Just did a quick search in the
> archives and didn't find anything that was 100% relevant.
>     I have a table with a date field, where some of the rows are empty
> (with NULL values) and some aren't. I need to make a "SELECT <blah blah>
> ORDER BY date DESC" but my customer wants the rows with empty values to
> appear at the bottom of the result set, instead of at the top. Is this
> possible?

You can use expressions in order by, so it is possible to do. One option
is to use coalesce if there is something safe to map nulls to always
get the right ordering. There are other ways to make this work if you
don't have a bound on the dates.

pgsql-general by date:

Previous
From: "Henrik Steffen"
Date:
Subject: Re: Serious Crash last Friday
Next
From: "Henrik Steffen"
Date:
Subject: Re: Serious Crash last Friday