Group: pgsql.sql


Subject: (repost) Help understanding expressions in order by clause
From: tgl@sss.pgh.pa.us (Tom Lane)
Date: 10/25/2007 1:03:21 PM
Steve Midgley <public@misuse.org> writes: > select * from test_order > order by id <> 3, email > --sql end > Putting the expression "id <> 3" causes the id of 3 to sort to the TOP > of the list. This statement does the same thing: > select * from test_order > order by id = 3 DESC, email > I know there is a good, rational reason for this, and I'm hoping > someone will explain it to me? These expressions yield boolean true or false, and false sorts before true. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster