On Sat, 14 Jun 1997, Thomas G. Lockhart wrote:
> Constantin Teodorescu wrote:
> > PostgreSQL 6.1 , Linux RedHat 4.2 Kernel 2.0.30
> > Selecting all records and ordering ascending and descending on a field :
> > template1=> select * from pers order by cod;
> > template1=> select * from pers order by cod desc;
> > ("cod" fields which are null _always_ show up at the end)
>
> This is an interesting feature. The reason for this behavior is that
> "null" fields should (I think) always return FALSE in comparisons, and
> the order-by is done using "<" or ">" operators. Remember, "null" is
> nothing, *not anything*, and hence is not comparable to anything which
> is not null. Even two null values should compare FALSE, I think.
>
absolutely correct: true != NULL; false != NULL; NULL != NULL;
I'm not sure whether its part of the standard but most databases implement
the 'is' keyword as in: ...where xyx is NULL or xyz is NOT NULL;
as for sort order, hmm. i would intuitively consider nulls to sort after
everything else, but i'm not sure what the standard says
sean
________________________________________________________________________
Sean Lyndersay Time is natures way of making sure
lynders@hcs.harvard.edu things don't happen all at once.
________________________________________________________________________
[finger for all other info] http://www.hcs.harvard.edu/~lynders
------------------------------