Thank you Igor!  Now I understand.

Caureus



Igor Tandetnik wrote:
> 
> caurues <caureu...@aol.com> wrote:
>> I am hoping I can get an answer to my question. I want to sort a column
>> in
>> ascending order, but I want null values to sort to the bottom. A simple
>> ORDER BY ColumnA ASC sorts the column in ascending order with null vales
>> appearing on top. The following code, however, works correctly, but I
>> have
>> no idea why: ORDER BY ColumnA IS NULL ASC, ColumnA ASC.
> 
> You are not limited to sorting just by a column name - you can sort by any
> expression. In particular, the expression (ColumnA IS NULL) evaluates to 0
> when the column is not null, and to 1 when it is. Then these zeros and
> ones are sorted in ascending order. This has the net effect of putting
> non-null values first and null values at the end.
> -- 
> Igor Tandetnik
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Sorting-Question-tp31378319p31383160.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to