From: | Jerome Alet <alet(at)librelogiciel(dot)com> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: How do you compare (NULL) and (non-NULL)? |
Date: | 2004-10-26 21:01:29 |
Message-ID: | 20041026210129.GC5922@localhost.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Tue, Oct 26, 2004 at 01:48:48PM -0700, Stephan Szabo wrote:
> 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.
you could try to use COALESCE to treat NULLs as either a minimal or
maximal value so that your ordering is correct :
SELECT Parent FROM Channels ORDER BY COALESCE(Parent, -1) ASC;
to treat NULLs as -1 for example
hth
Jerome Alet
From | Date | Subject | |
---|---|---|---|
Next Message | Yudie | 2004-10-26 21:32:57 | Re: How to re-sort a sorted query? |
Previous Message | Stephan Szabo | 2004-10-26 20:48:48 | Re: How do you compare (NULL) and (non-NULL)? |