Home » RDBMS Server » Server Administration » Query regarding ORDER BY clause
Query regarding ORDER BY clause [message #372500] Thu, 15 February 2001 20:18 Go to next message
ramesh
Messages: 123
Registered: August 2000
Senior Member
Hi,

Suppose i have a list of employee names as follows:
aaa,AAA,abc,ABC,aBcd,ABCD,bbb,BBB
Is it possible to sort the data in the following manner?
aaa
abc
aBcd
bbb
AAA
ABC
ABCD
BBB

That is order by all the lower cased names first and then sort the names in upper case.

Please mail me if this can be done.

Thanks,
Ramesh
Re: Query regarding ORDER BY clause [message #372508 is a reply to message #372500] Fri, 16 February 2001 08:47 Go to previous messageGo to next message
Bala
Messages: 205
Registered: November 1999
Senior Member
try??
order by emp_name desc;
Re: Query regarding ORDER BY clause [message #372513 is a reply to message #372500] Fri, 16 February 2001 12:36 Go to previous message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
This is not very efficient, but could work for you. You could try checking ranges (where ascii(col1) >= 65) etc.

create table a (col1 varchar2(10));

insert into a values ('Aa')

insert into a values ('aa')

insert into a values ('Ba')

insert into a values ('ba')

insert into a values ('Ca')

insert into a values ('ca')

insert into a values ('Za')

insert into a values ('za')

select col1, 1, ascii(col1) from a where ascii(col1) -- ascii on 1st char!
= ascii(lower(col1))
UNION ALL
select col1, 2, ascii(col1) from a where ascii(col1) -- ascii on 1st char!
= ascii(upper(col1))
order by 2, 1;
Previous Topic: Insert into
Next Topic: Re: Alright Smart Guys... Here's a simple one.
Goto Forum:
  


Current Time: Sat May 18 05:49:00 CDT 2024