Re: Problem of Null Ordering

From: Dennis Björklund <db(at)zigo(dot)dhs(dot)org>
To: Harry Yau <harry(dot)yau(at)regaltronic(dot)com>
Cc: PGG <pgsql-general(at)postgresql(dot)org>
Subject: Re: Problem of Null Ordering
Date: 2002-12-03 09:33:12
Message-ID: Pine.LNX.4.44.0212031028380.9578-100000@zigo.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

On Tue, 3 Dec 2002, Harry Yau wrote:

> NULL will come after the row that have a number value. I am wondering is
> there anything I can do to make the row with Null value come before the
> row with a number value.

I don't know of such a setting. I have however a workaround that you can
apply to the order by clause. If b is the column that contains NULL values
that you want to order by, then you can instead order in this way:

ORDER BY b IS NULL DESC, b

(or ORDER BY b IS NOT NULL, b)

which will give you the NULL values first. It's probably not standard SQL.

ps. Why post to several lists?

--
/Dennis

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Harry Yau 2002-12-03 09:54:13 Re: [GENERAL] Problem of Null Ordering
Previous Message Jean-Christian Imbeault 2002-12-03 09:31:52 Re: Problem of Null Ordering

Browse pgsql-general by date

  From Date Subject
Next Message Karel Zak 2002-12-03 09:45:41 Re: 7.4 Wishlist
Previous Message Jean-Christian Imbeault 2002-12-03 09:31:52 Re: Problem of Null Ordering