Go Back   Rhinocerus > Newsgroup > Newsgroup comp.databases.oracle.server

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 07-11-2007, 12:59 PM
kilik3000@gmail.com
Guest
 
Posts: n/a
Default sorting in oracle?

If I create a table:

CREATE TABLE FOO
(
BAR VARCHAR(5)
);

insert into foo values ('a');
insert into foo values ('b');
insert into foo values ('c');
insert into foo values ('A');
insert into foo values ('B');
insert into foo values ('C');

and run this select statement:

select bar from foo order by bar;

I get back:

BAR
-----
A
B
C
a
b
c

Why don't I get back...

BAR
-----
A
a
B
b
C
c

-Thx

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 07-11-2007, 01:03 PM
sybrandb
Guest
 
Posts: n/a
Default Re: sorting in oracle?

On Jul 11, 2:59 pm, kilik3...@gmail.com wrote:
> If I create a table:
>
> CREATE TABLE FOO
> (
> BAR VARCHAR(5)
> );
>
> insert into foo values ('a');
> insert into foo values ('b');
> insert into foo values ('c');
> insert into foo values ('A');
> insert into foo values ('B');
> insert into foo values ('C');
>
> and run this select statement:
>
> select bar from foo order by bar;
>
> I get back:
>
> BAR
> -----
> A
> B
> C
> a
> b
> c
>
> Why don't I get back...
>
> BAR
> -----
> A
> a
> B
> b
> C
> c
>
> -Thx



Answers are usually version dependent. 5 digits and 3 dots.
The answer to your question is Oracle by default has NLS_SORT=binary,
which results in everything being ordered in the order of the ASCII
characterset.l
Case insensitive sorting is available in 10g and higher.

--
Sybrand Bakker
Senior Oracle DBA


Reply With Quote
  #3 (permalink)  
Old 07-11-2007, 01:17 PM
fitzjarrell@cox.net
Guest
 
Posts: n/a
Default Re: sorting in oracle?

On Jul 11, 7:59 am, kilik3...@gmail.com wrote:
> If I create a table:
>
> CREATE TABLE FOO
> (
> BAR VARCHAR(5)
> );
>
> insert into foo values ('a');
> insert into foo values ('b');
> insert into foo values ('c');
> insert into foo values ('A');
> insert into foo values ('B');
> insert into foo values ('C');
>
> and run this select statement:
>
> select bar from foo order by bar;
>
> I get back:
>
> BAR
> -----
> A
> B
> C
> a
> b
> c
>
> Why don't I get back...
>
> BAR
> -----
> A
> a
> B
> b
> C
> c
>
> -Thx


Consult a table of ASCII characters and you'll realise the capital
letters have lower ASCII values than the lower case letters. The sort
is based upon the ASCII code. A quick search on Google would have
provided numerous links to explain this.


David Fitzjarrell

Reply With Quote
  #4 (permalink)  
Old 07-11-2007, 02:07 PM
Mladen Gogala
Guest
 
Posts: n/a
Default Re: sorting in oracle?

On Wed, 11 Jul 2007 05:59:54 -0700, kilik3000 wrote:

> Why don't I get back...


Because Oracle hates you.

--
http://www.mladen-gogala.com
Reply With Quote
 
Reply

Thread Tools
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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Problems loading character variables into Oracle Gerry Newsgroup comp.soft-sys.sas 0 11-15-2006 08:29 PM
Re: SAS 9.1.3, Oracle 10G And Oracle RAC Gerry Newsgroup comp.soft-sys.sas 1 11-10-2006 11:15 AM
Re: SAS and Oracle Olivier LECONTE Newsgroup comp.soft-sys.sas 2 12-14-2005 04:39 AM
SAS Access to Oracle ma015b8234 Newsgroup comp.soft-sys.sas 0 06-02-2005 06:23 PM



All times are GMT. The time now is 11:54 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.