Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL : Order by for varchar ???
How about keeping a hidden field out in the table that has a trigger that, when an insert or update is done, it takes the varchar value, goes thru some magic, and converts it to the decimal equivalent. I mean, what if you have mixed 1' 3 1/4 ". You would have to convert this to 15.25 then store it. THEN do your ordering on this field.
Or, if you do have a function that can look at the value and convert it on the fly, just order by that function acting upon the data field.
Such as Select * from test order by width_converter(width);
-----Original Message-----
Sent: Thursday, June 07, 2001 12:56 PM
To: Multiple recipients of list ORACLE-L
One of our developers was looking for solution for his problem ..
Any idea folks .. ??
He wants to sort his data asc or desc for a varchar column ..
1> create table test(width varchar2(20));
2>
insert into test values('5/8"'); insert into test values('4"'); insert into test values('3/4"');
3>
select width from test order by width DESC;
5/8"
3/4"
1"
1-1/2"
2"
4"
Cheers
RK
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Apps Sol
INET: apps_sol_at_hotmail.com
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists --------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Thu Jun 07 2001 - 14:29:30 CDT