db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Satheesh Bandaram <sathe...@Sourcery.Org>
Subject Re: About improvement of DERBY-134
Date Sat, 12 Mar 2005 03:19:24 GMT
Also, if we disallow C1/C1, how about (C1+C2)/(C2+C1)? Same question for
(C1+C1)/2*C1. How intelligent do we need to make this thing? I still
vote for the simplest approach, proposed by Jeremy. I also tried this on
DB2 that I have access to. This what is proposed by Tomohito and Jeremy
matches that behaviour.

Satheesh

db2 => select * from t
I           J
----------- -----------
          1           1
          2           2
          0           4
          5           0
db2 => select * from t order by 1+1
I           J
----------- -----------
          1           1
          2           2
          0           4
          5           0
db2 => select * from t order by 2
I           J
----------- -----------
          5           0
          1           1
          2           2
          0           4
Jeremy Boynes wrote:

> Daniel John Debrunner wrote:
>
>>
>  > If it made it clearer I would prefer that a compilation error is
> raised
>
>> for order by expressions that do resolve to constants, since supporting
>> them adds no value. How this error would be raised I'm not sure about.
>>
>> ORDER BY 1 - ok (column position 1)
>> ORDER BY C1 - ok
>> ORDER BY FN(C1) - ok
>> ORDER BY 1 + 1 - disallow
>> ORDER BY C1/C1 - disallow
>>
>
> The spec says that the sort keys are value expressions which would
> make both "ORDER BY 1+1" and "ORDER BY C1/C1" valid SQL so we can't
> raise an error.
>
> In both cases the result is implementation dependent as the key will
> be the same for all rows. I think /choosing/ to define the result when
> the value expression is a simple integer literal is useful so we can
> support the "ORDER BY 1,2" syntax common on other platforms; I believe
> anything more complex than that is going to be confusing.
>
> This may make the parser more complex, but that's a development issue
> not a user one :-)
>
> -- 
> Jeremy
>
>


Mime
View raw message