[ http://issues.apache.org/jira/browse/DERBY-280?page=comments#action_12357330 ]
Satheesh Bandaram commented on DERBY-280: ----------------------------------------- I agree the patch is not fixable to make this query work... Your patch currently assumes two instances of expressions are not equivalent and it is not easy to confirm it. I tried similar querries on DB2, that I have access to. DB2 handles them correctly... without raising an error. Guess they don't have the query rewrite issue Derby does. I also attempted to "fix" the problem some time ago... I tried your second approach, match by position. The patch was getting ugly, like you mentioned, so I also abandoned going that way. As I see it, your patch improves the situation from what we have today, but also incorrectly fails on a much smaller number of querries. I wouldn't mind committing the patch... Anyone else have any other comments? > Wrong result from select when aliasing to same name as used in group by > ----------------------------------------------------------------------- > > Key: DERBY-280 > URL: http://issues.apache.org/jira/browse/DERBY-280 > Project: Derby > Type: Bug > Components: SQL > Reporter: Bernt M. Johnsen > Assignee: Rick Hillegas > Priority: Minor > Attachments: bug280.diff > > Wrong result from select when aliasing to same name as used in group by. > Example: > If we have the following table: > ij> select * from tt; > I |J > ----------------------- > 1 |2 > 2 |3 > 1 |2 > 2 |3 > 2 |3 > > > 5 rows selected > The following select is ok: > ij> select i, count(*) as cnt from tt group by i; > I |CNT > ----------------------- > 1 |2 > 2 |3 > > > 2 rows selected > But this one returns wrong result in the aliased column: > ij> select i, count(*) as i from tt group by i; > I |I > ----------------------- > 1 |1 > 2 |2 > > > 2 rows selected > > -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
