Re: [sqlite] Sorting Question

2011-04-12 Thread caurues

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


[sqlite] Sorting Question

2011-04-12 Thread caurues

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. Can someone please
explain why? I also tried ORDER BY ColumnA IS NULL ASC and this code sorted
only the null values to the bottom of the remaining unsorted list, which I
do not understand. I guess what I am not understanding is why the result of
filtering within an ORDER BY clause appears at the bottom of my list.
-- 
View this message in context: 
http://old.nabble.com/Sorting-Question-tp31378319p31378319.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