Subject Re: [ib-support] Re: ORDER BY as number when not
Author Martijn Tonies
Hi,

> >> [ order by cast suggestion: ]
> >>
> >>> Yes, tried that. no luck
> >>
> >> OK, 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.
> >
> > Unfortunately this will work only if values in selected strings will
> > contain only digits. More general solution I think will be store
> > such a columns with leading spaces or add them on select using UDF.

Actually - WHO decides that this would be the right order:

1
11
20
A
AA
BA

??

What kind of order is this? This is a very custom order...


With regards,

Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
http://www.upscene.com