Subject Re: [firebird-support] Strange behaviour with ORDER BY
Author Arno Brinkman
Hi Heiko,

> It's not a problem for me but I just came across this strange
> behaviour of Firebird 1.5.2
>
> Firebird notices wrong column-positions like this
>
> SELECT col1, col2, col3 FROM ... ORDER BY 0
> or
> SELECT col1, col2, col3 FROM ... ORDER BY 4
>
> But it also accepts commands like this
>
> SELECT col1, col2, col3 FROM ... ORDER BY -1
> SELECT col1, col2, col3 FROM ... ORDER BY 1+1
> SELECT col1, col2, col3 FROM ... ORDER BY 3-1
> ...
>
> but doesn't give the "expected" results or errors.

Well, it depends on what you expect ;-)

1+1 is an expression, thus you're sorting on the value 2 (not column position 2)!

Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
General database developer support:
http://www.databasedevelopmentforum.com

Firebird open source database (based on IB-OE) with many SQL-99 features:
http://www.firebirdsql.org
http://www.firebirdsql.info

Support list for Interbase and Firebird users:
firebird-support@yahoogroups.com

Nederlandse firebird nieuwsgroep:
news://newsgroups.firebirdsql.info