how to use ORDER BY clause in VARCHAR2 datatype column? [message #267324] |
Thu, 13 September 2007 01:02  |
sbmk_design
Messages: 88 Registered: April 2007 Location: CHENNAI
|
Member |
|
|
Hi
SQl> select equipment_no from equipment_master order by equipment_no;
Equipment_no(varchar2)
----------------------
1
12
111
134
1205
2
245
3
313
aluminium casting
drill machine
power press
I wanted to arrange varchar2 datatype column in accending order.Both number,char should come in accending order.
(i.e I am expecting o/p like this
Equipment_no(varchar2)
----------------------
1
2
3
12
111
134
245
313
1025
aluminium casting
drill machine
power press. is it possible?
by
sbmk_design
[Updated on: Thu, 13 September 2007 01:03] Report message to a moderator
|
|
|
|
|
|
|
|
Re: how to use ORDER BY clause in VARCHAR2 datatype column? [message #267642 is a reply to message #267374] |
Fri, 14 September 2007 01:32   |
bonker
Messages: 402 Registered: July 2005
|
Senior Member |
|
|
does this help?
scott@test>desc test
Name Null? Type
----------------------------------------- -------- ----------------------------
X VARCHAR2(10)
scott@test>select * from test;
X
----------
1
100
2
9
999
alum
brass
scott@test>select x from test order by lpad(x,10,' ');
X
----------
1
2
9
100
999
alum
brass
7 rows selected.
scott@test>insert into test values('200');
1 row created.
scott@test>select x from test order by lpad(x,10,' ');
X
----------
1
2
9
100
200
999
alum
brass
8 rows selected.
scott@test>
I still feel it may not work in all cases.
[Updated on: Fri, 14 September 2007 01:34] Report message to a moderator
|
|
|
|