Re: Problem of Null Ordering

Поиск
Список
Период
Сортировка
От SZUCS Gábor
Тема Re: Problem of Null Ordering
Дата
Msg-id 003c01c29ab8$45fe5130$0a03a8c0@fejleszt2
обсуждение исходный текст
Ответ на Problem of Null Ordering  (Harry Yau <harry.yau@regaltronic.com>)
Список 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.yau@regaltronic.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



В списке pgsql-general по дате отправления:

Предыдущее
От: Lee Kindness
Дата:
Сообщение: 7.3 -> pg_atoi: zero-length string
Следующее
От: "Ben-Nes Michael"
Дата:
Сообщение: Re: 7.3 -> pg_atoi: zero-length string