Re: [sqlite] ANSI order by

2007-09-07 Thread Dennis Cote

Andre du Plessis wrote:

Sorry if this is actually a noob question, how do I do an ansi style
order by in sqlite

For example

 


A

b

a

B

 


Would be sorted as

 


A

B

a

b

 


but what you want is

 


a

A

b

B

 


I can do order by upper(column)

But then things like

 


__new__

 


Goes to the bottom and should go to the top

 


Thanks.


  
You should use lower(column) instead. This will convert uppercase to 
lowercase and sort *most* punctuation characters before the alphabetic 
characters. Note that '{', '|', '}', and '~' will still sort after all 
the alphabetic characters.


If you want the lower case columns to come before the uppercase values 
(as you show in your example) you will also have to sort by the original 
column values in descending order (so 'a' 0x61 comes before 'A' 0x41).


   order by lower(a_column), a_column desc

Or you could write and register your own collation function which does 
exactly what you want. :-)


HTH
Dennis Cote

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] ANSI order by

2007-09-07 Thread Andre du Plessis
Sorry if this is actually a noob question, how do I do an ansi style
order by in sqlite

For example

 

A

b

a

B

 

Would be sorted as

 

A

B

a

b

 

but what you want is

 

a

A

b

B

 

I can do order by upper(column)

But then things like

 

__new__

 

Goes to the bottom and should go to the top

 

Thanks.