You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by T E Schmitz <ma...@numerixtechnology.de> on 2004/09/19 18:22:26 UTC

[psql] ORDER BY IS NOT NULL

Hello,

In PostGreSQL NULL values sort last. The following SQL statement will
sort them at the top:

SELECT * FROM <table> ORDER BY <col> IS NOT NULL, ORDER BY <col> ASC

or alternatively

SELECT * FROM <table> ORDER BY COALASCE(<col>,0) ASC
In this example NULLs are mapped to zero, i.e. one would choose the 
lowest possible value.


Result

<col>
-------------
NULL
12
13
16
18

How can this be done via Torque Criteria?

-- 


Regards/Gruß,

Tarlika Elisabeth Schmitz



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org