Query regarding ORDER BY clause [message #372500] |
Thu, 15 February 2001 20:18 |
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 #372513 is a reply to message #372500] |
Fri, 16 February 2001 12:36 |
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;
|
|
|