Subject | Re: [ib-support] ORDER BY as number when not |
---|---|
Author | Paul Vinkenoog |
Post date | 2003-05-30T22:27:05Z |
Hi Todd,
[ order by cast suggestion: ]
select cast ( my_char_column as <int or float type here> )
, ...
, ...
from mytable
order by 1
Or define computed columns for the casts and order on those columns
when you need to. If you need to do that often, add real numerical
columns and populate them in after insert/update triggers.
Greetoz,
Paul
[ order by cast suggestion: ]
> Yes, tried that. no luckOK, too bad. This one works however:
select cast ( my_char_column as <int or float type here> )
, ...
, ...
from mytable
order by 1
Or define computed columns for the casts and order on those columns
when you need to. If you need to do that often, add real numerical
columns and populate them in after insert/update triggers.
Greetoz,
Paul
>>> We have a table that has a number of different kinds of codes in
>>> it. Some are numbers and some are not, so the code itself is
>>> defined as a CHAR.
>>>
>>> Is it possible to order the data numerically in a select statement
>>> even when it isn't so the data comes out like:
>>>
>>> 1
>>> 2
>>> 3
>>> 11
>>>
>>> instead of
>>>
>>> 1
>>> 11
>>> 2
>>> 3