From: | SZUCS Gábor <surrano(at)mailbox(dot)hu> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Problem of Null Ordering |
Date: | 2002-12-03 10:39:33 |
Message-ID: | 003c01c29ab8$45fe5130$0a03a8c0@fejleszt2 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-general |
I often use this trick:
SELECT * FROM t1 ORDER BY (IF1 IS NOT NULL), if1;
The first order is by a boolean value, and false comes first. Effectively,
it's the same thought as the union. But if you fear boolean expressions, try
this:
SELECT * FROM t1 ORDER BY (CASE WHEN if1 IS NULL THEN 0 ELSE 1 END), if1;
HTH,
G.
--
while (!asleep()) sheep++;
---------------------------- cut here ------------------------------
----- Original Message -----
From: "Harry Yau" <harry(dot)yau(at)regaltronic(dot)com>
Sent: Tuesday, December 03, 2002 10:54 AM
> I know that it is possible to do this query. Such as
> SELECT *, 0 AS PreOrder FROM T1 WHERE IF1 IS NULL
> UNION ALL
> SELECT *, 1 AS PreOrder FROM T1 WHERE IF1 IS NOT NULL
> ORDER BY PreOrder, IF1
From | Date | Subject | |
---|---|---|---|
Next Message | =?ISO-8859-2?Q?M.K=F6nig?= | 2002-12-03 11:34:45 | Re: dumb question: how to get a list of databases? |
Previous Message | Harry Yau | 2002-12-03 09:54:13 | Re: [GENERAL] Problem of Null Ordering |
From | Date | Subject | |
---|---|---|---|
Next Message | Ben-Nes Michael | 2002-12-03 10:50:41 | Re: 7.3 -> pg_atoi: zero-length string |
Previous Message | Lee Kindness | 2002-12-03 10:37:48 | 7.3 -> pg_atoi: zero-length string |