X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9B1658B9B3A for ; Wed, 16 Feb 2005 00:56:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50807-10 for ; Wed, 16 Feb 2005 00:56:01 +0000 (GMT) Received: from krogh.officenet.no (unknown [128.39.244.194]) by svr1.postgresql.org (Postfix) with ESMTP id 2E5D88BA099 for ; Wed, 16 Feb 2005 00:55:59 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by krogh.officenet.no (Postfix) with ESMTP id A06A378465 for ; Wed, 16 Feb 2005 00:55:59 +0000 (UTC) From: Andreas Joseph Krogh Organization: OfficeNet AS To: pgsql-sql@postgresql.org Subject: Making NULL entries appear first when ORDER BY ASC Date: Wed, 16 Feb 2005 00:55:54 +0000 User-Agent: KMail/1.7.92 MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3303793.XtD92VhEQi"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200502160055.59288.andreak@officenet.no> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200502/154 X-Sequence-Number: 20265 --nextPart3303793.XtD92VhEQi Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I have the following table, with the query below to list entries from i= t=20 where start_date IS NOT NULL: CREATE TABLE onp_crm_activity_log( id serial PRIMARY KEY, start_date timestamp, start_time timestamp, end_time timestamp, title varchar NOT NULL ); SELECT start_date, start_time, end_time, title =46ROM onp_crm_activity_log WHERE start_date IS NOT NULL ORDER BY start_date ASC, start_time ASC; start_date | start_time | end_time | title =2D--------------------+---------------------+---------------------+-------= =2D--- 2005-02-03 00:00:00 | 2005-02-03 08:00:00 | | Something 2005-02-03 00:00:00 | 2005-02-03 09:00:00 | 2005-02-03 12:00:00 | Something 2005-02-03 00:00:00 | | | Something Now, as you see, touples with NULL in the "start_time"-field appear "after"= =20 the others. I would like to make all entries where start_time IS NULL apear= =20 *before* all the others. Any idea how to achieve this? =2D-=20 Andreas Joseph Krogh Senior Software Developer / Manager gpg public_key: http://dev.officenet.no/~andreak/public_key.asc =2D-----------------------+---------------------------------------------+ OfficeNet AS | The most difficult thing in the world is to | Hoffsveien 17 | know how to do a thing and to watch | PO. Box 425 Sk=F8yen | somebody else doing it wrong, without | 0213 Oslo | comment. | NORWAY | | Phone : +47 22 13 01 00 | | Direct: +47 22 13 10 03 | | Mobile: +47 909 56 963 | | =2D-----------------------+---------------------------------------------+ --nextPart3303793.XtD92VhEQi Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQBCEpofUopImDh2gfQRAlaJAJ9I9dRs22WxLJBH6oJVI5DDBoa1FgCfVN0c 3kFsdV9NIfgAfi8mCeOFNHw= =vsBD -----END PGP SIGNATURE----- --nextPart3303793.XtD92VhEQi--