Re: Making NULL entries appear first when ORDER BY ASC - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: Making NULL entries appear first when ORDER BY ASC
Date
Msg-id 20050216044735.GA2343@wolff.to
Whole thread Raw
In response to Making NULL entries appear first when ORDER BY ASC  (Andreas Joseph Krogh <andreak@officenet.no>)
Responses Re: Making NULL entries appear first when ORDER BY ASC
List pgsql-sql
> 
> Now, as you see, touples with NULL in the "start_time"-field appear "after" 
> the others. I would like to make all entries where start_time IS NULL apear 
> *before* all the others. Any idea how to achieve this?

SELECT start_date, start_time, end_time, title
FROM onp_crm_activity_log
WHERE start_date IS NOT NULL
ORDER BY start_date ASC, start_time IS NOT NULL ASC, start_time ASC;

This assumes you want the NULL start times first within a particular
date. Otherwise change the order in the ORDER BY clause.


pgsql-sql by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: Making NULL entries appear first when ORDER BY ASC
Next
From: "Keith Worthington"
Date:
Subject: More efficient OR