Subject | Re: Sort Order Query |
---|---|
Author | Adam |
Post date | 2007-05-29T04:16:47Z |
--- In firebird-support@yahoogroups.com, "Alan McDonald" <alan@...> wrote:
use something like this, which only requires the built in UDFs.
select *
from foo
order by case when strlen(bar) = 1 then -1 else cast(Substr(bar, 1,
strlen(bar)-1) as Integer) end,
bar
If there are a varied number of Alpha characters, or they are in
varying positions, it could probably be done with enough gymnastics.
(I couldn't get the built in substring command to work with the 'for'
parameter being an expression returned from a UDF).
Adam
>resorting to a
> I have a table with a field value like this:
> 1A
> 1B
> ..
> 2A
> ..
> 9A
> 10A
> 11A
> 11B
>
>
> etc
>
> does anyone know a sneaky way of ordering this column without
> separate sort order column or renaming 1A to 01A etc, such that 1A comesIs it only a single character in the field? If so, you can probably
> first (ie. not after 10A)?
use something like this, which only requires the built in UDFs.
select *
from foo
order by case when strlen(bar) = 1 then -1 else cast(Substr(bar, 1,
strlen(bar)-1) as Integer) end,
bar
If there are a varied number of Alpha characters, or they are in
varying positions, it could probably be done with enough gymnastics.
(I couldn't get the built in substring command to work with the 'for'
parameter being an expression returned from a UDF).
Adam