From: | Rod Taylor <rbt(at)rbt(dot)ca> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
Cc: | Ian Burrell <ib(at)onsitetech(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Sorting by NULL values |
Date: | 2003-03-04 22:01:59 |
Message-ID: | 1046815319.15229.87.camel@jester |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)postgresql(dot)org)
--
Rod Taylor <rbt(at)rbt(dot)ca>
PGP Key: http://www.rbt.ca/rbtpub.asc
From | Date | Subject | |
---|---|---|---|
Next Message | Miriam Fernández Galicia | 2003-03-04 22:24:21 | unsuscribe |
Previous Message | Tomasz Myrta | 2003-03-04 21:35:09 | Re: LIMIT and SUBQUERIES |