Search Postgresql Archives

Re: Order By and Comparisson

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 07 Apr 2014 11:04:23 +0100
"howardnews@xxxxxxxxxxxxx" <howardnews@xxxxxxxxxxxxx> wrote:

> Hi,
> 
> just as I thought I had postgres mastered :)  the ordering of strings is 
> causing me some confusion.
> 
> Can someone explain how the database orders strings in the ORDER BY command.
> 
> My example:
> 
> My database is encoding is UTF-8, and default language is english,
> 
> If I have a text column in a table with the following rows:
> 
> 'a'
> 'A'
> '~'
> 
> Then in UTF-8, I would expect the order to give me
> 
> 'A'
> 'a'
> '~'
> 
> But instead I get:
> 
> '~'
> 'a'
> 'A'
> 
> Is there anywhere in the documentation I can get a more detailed 
> explanation of this?

Expect for the unexpected. SQL alphabetical sorting can get pretty complicated,
as stated in this note from Oracle 10g Release 2 docs[1]:

"In the ASCII standard, all uppercase letters appear before any lowercase letters.
 In the EBCDIC standard, the opposite is true: all lowercase letters appear before
 any uppercase letters".

[1] docs.oracle.com/cd/B19306_01/server.102/b14225/ch5lingsort.htm

-- 
Alberto Cabello Sánchez
<alberto@xxxxxxx>


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux