If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Problem with order by of varchar

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-02-11, 19:57
jacquesmarques jacquesmarques is offline
Registered User
 
Join Date: Sep 2011
Posts: 1
Problem with order by of varchar

Hi,

I has a table of names with this data:

GABRIELA CARVALHO
GRABIEL ALVES

When I try:

select name from table order by name

Thes system return:

GABRIELA CARVALHO
GRABIEL ALVES

But this is wrong, the correct is:

GRABIEL ALVES
GABRIELA CARVALHO

Because GRABRIEL has less letter than GABRIELA.

Why this happen and how fix?

Thanks
Reply With Quote
  #2 (permalink)  
Old 09-06-11, 05:12
rski rski is offline
Registered User
 
Join Date: Nov 2006
Posts: 82
Of course you are wrong,

'GABRIELA'<'GRABIEL' because the first word has 'A' on the second position and the second has 'R'. Letter A is much before R.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On