SQL for sorting boolean column as true, null, false
Posted
by petehern
on Stack Overflow
See other posts from Stack Overflow
or by petehern
Published on 2010-05-13T15:39:38Z
Indexed on
2010/05/13
16:04 UTC
Read the original article
Hit count: 236
My table has three boolean fields: f1, f2, f3. If I do
SELECT * FROM table ORDER BY f1, f2, f3
the records will be sorted by these fields in the order false, true, null. I wish to order them with null in between true and false: the correct order should be true, null, false.
I am using PostgreSQL.
© Stack Overflow or respective owner