From: Bruno Wolff III <bruno@wolff.to>
To: Andreas Joseph Krogh <andreak@officenet.no>
Cc: pgsql-sql@postgresql.org
Subject: Re: Making NULL entries appear first when ORDER BY <field> ASC
Date: Tue, 15 Feb 2005 22:47:35 -0600
Message-ID: <20050216044735.GA2343@wolff.to> (raw)
In-Reply-To: <200502160055.59288.andreak@officenet.no>
References: <200502160055.59288.andreak@officenet.no>
>
> 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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bruno@wolff.to, andreak@officenet.no
Subject: Re: Making NULL entries appear first when ORDER BY <field> ASC
In-Reply-To: <20050216044735.GA2343@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox